Advertisement
Manunich

Untitled

Aug 5th, 2013
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. const int MAX=255;
  4. char a[MAX], s[MAX];
  5. int k=0;
  6. int main() {
  7.     cin>>s;
  8.     for(int i = 0; i <strlen(s); i++) {
  9.         if ((s[i]=='(' || s[i]=='[' || s[i]=='{') && k<MAX) a[++k]=s[i];
  10.         if ((s[i]==')' && a[k]=='(' || s[i]==']' && a[k]=='[' || s[i]=='}' && a[k]=='{') && k>=1) k--;
  11.     }
  12.     if (k==0) cout<<"no"; else cout<<"yes";
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement