Advertisement
TimxAG

Untitled

Dec 11th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. int main()
  2. {
  3. char ch;int n,i,k,f1=0,f2=0,f3=0,f=1;
  4. cin >> n;
  5. fo(i,n)
  6. {
  7. cin >> ch;
  8. if (ch=='(') f1++;
  9. if (ch=='{') f3++;
  10. if (ch=='[') f2++;
  11. // cout << f1<<endl;
  12. if ((ch==')') && (f1>0)) f1--; else if ((ch==')') && (f1==0)) f=0;
  13. if ((ch==']') && (f2>0)) f2--; else if ((ch==']') && (f2==0)) f=0;
  14. if ((ch=='}') && (f3>0)) f3--; else if ((ch=='}') && (f3==0)) f=0;
  15. }
  16. if ((f1==0) && (f2==0) && (f3==0) && (f==1)) cout << "Ja"; else cout << "Nein";
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement