Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- char ch;int n,i,k,f1=0,f2=0,f3=0,f=1;
- cin >> n;
- fo(i,n)
- {
- cin >> ch;
- if (ch=='(') f1++;
- if (ch=='{') f3++;
- if (ch=='[') f2++;
- // cout << f1<<endl;
- if ((ch==')') && (f1>0)) f1--; else if ((ch==')') && (f1==0)) f=0;
- if ((ch==']') && (f2>0)) f2--; else if ((ch==']') && (f2==0)) f=0;
- if ((ch=='}') && (f3>0)) f3--; else if ((ch=='}') && (f3==0)) f=0;
- }
- if ((f1==0) && (f2==0) && (f3==0) && (f==1)) cout << "Ja"; else cout << "Nein";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement