Advertisement
Znta777

Untitled

Nov 27th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3. #include <string>
  4. using namespace std;
  5. int main()
  6. {
  7. string st;
  8. int i=0;
  9. cin>>st;
  10.  
  11. while (true){
  12. i=0;
  13. while(st[i]!='\0'){
  14. if( st[i]=='[' && st[i+1]==']' ||st[i]=='(' && st[i+1]==')' || st[i]=='{' && st[i+1]=='}' ){
  15. st.erase(i,2);
  16. break;
  17. }
  18. i++;
  19. }
  20. if(st[i]=='\0'){
  21. if(st.size()==0)
  22. cout<<"YES";
  23. else {
  24. cout << "NO";
  25. }
  26.  
  27. break;
  28. }
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement