Advertisement
Rahdin

Untitled

Oct 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string arr;
  7. cin >> arr;
  8. int len=arr.size();
  9. bool k=true;
  10. for (int i=0; i<len; i++){
  11. if(arr[i]=='(' ){
  12. if (arr[i+1]=='}' or arr[i+1]==']'){
  13. k=false;
  14. break;
  15. }
  16. }
  17. else if (arr[i]=='{'){
  18. if (arr[i+1]==')' or arr[i+1]==']'){
  19. k=false;
  20. break;
  21. }
  22. }
  23. else if (arr[i]=='['){
  24. if (arr[i+1]==')' or arr[i+1]=='}'){
  25. k=false;
  26. break;
  27. }
  28. }
  29.  
  30. else if (arr[i]=='{' and arr[i+1]==')' or arr[i+1]==']'){
  31.  
  32. }
  33.  
  34. }
  35. if (k==true){
  36. cout << "Yes";
  37. }
  38. else {
  39. cout << "No";
  40. }
  41.  
  42. return 0;
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement