Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void push(char m);
- void pop();
- int i, top=-1;
- char s[20];
- void main()
- {
- char a[]="(sangeet(h))";
- i=0;
- push('#');
- while(a[i++]!='\n')
- {
- if(a[i]==')')
- {
- pop();
- }
- if(a[top]=='#')
- printf("valid");
- else
- printf("invalid");
- }
- void push(char m)
- {
- top++;
- s[top]=m;
- }
- void pop()
- {
- --top;
- }
Add Comment
Please, Sign In to add comment