#include<stdio.h>#include<string.h>#define maxsize 100
struct stack{   int A[maxsize]; int top;};      struct stack s;void push(int
index){ s.top++;        if(s.top==maxsize)      {               printf("cannot 
be pushed");     }
else    {               s.A[s.top]=index;       }}
int pop(){      int a;  a=s.top;        s.top--;                if(a==-1)       
{               return -1;      }       else
{                       return s.A[a];  }
}
int main(){     int i=0,res;    char str[100];
        scanf("%s",str);        s.top=-1;       for(i=0;i<strlen(str);i++)      
{
if(str[i]=='(')         {                       push(i);                }       
        else            {                       res=pop();              }       
        }
res=pop(s);     if(res!=-1)     printf("mismatch found at index %d
\n",s.A[0]);    }

On Dec 20, 7:40 pm, zeroByZero <shri.nit...@gmail.com> wrote:
> In a given string arrary arr[] = "((()())" or any other string return
> index for which no match is found as for this example is index 0 and
> for "()()()(()" is index 6

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to