Advertisement
wellWINeo

Untitled

Apr 8th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7.     string sentence;
  8.     getline( cin, sentence);
  9.     int circle = 0, square = 0, figure = 0;
  10.     for (int i = 0; i < sentence.size(); i++)
  11.     {
  12.         if ( circle >= 0 && square >= 0 && figure >= 0) {
  13.  
  14.  
  15.             switch (sentence[i]) {
  16.                 case '(':
  17.                     circle++;
  18.                     break;
  19.  
  20.                 case '[':
  21.                     square++;
  22.                     break;
  23.  
  24.                 case '{':
  25.                     figure++;
  26.                     break;
  27.  
  28.                 case ')':
  29.                     circle--;
  30.                     break;
  31.  
  32.                 case ']':
  33.                     square--;
  34.                     break;
  35.  
  36.                 case '}':
  37.                     figure--;
  38.                     break;
  39.  
  40.                 default:
  41.                     break;
  42.             }
  43.         }
  44.         else
  45.         {
  46.             break;
  47.         }
  48.     }
  49.  
  50.     if ((circle == 0) && (square == 0) && (figure == 0))
  51.     {
  52.         cout << " All right!\n";
  53.     }
  54.     else
  55.     {
  56.         cout << " Mistake!\n";
  57.     }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement