Advertisement
semenrbt

xap4ok chillout + full out + ball out

Nov 4th, 2020 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main(void) {  
  7.   string Str;
  8.   cin >> Str;
  9.   int k = 0, counter1 = 0, counter2 = 0, counter3 = 0, counter4 = 0;
  10.   int s = Str.size();
  11.   while(s > 0)
  12.   {
  13.     char c = Str[Str.size() - s];
  14.     if(c == 40) // ( )
  15.     {              
  16.       counter1++;
  17.     }
  18.     else
  19.     {
  20.       if(c == 41)
  21.       {
  22.         if(counter1 > 0)
  23.         {
  24.           counter1--;
  25.         }
  26.         else
  27.         {
  28.           printf("Dizbalance.\n");
  29.           return 0;
  30.         }
  31.       }
  32.     }
  33.     ///
  34.     if(c == 91) // 91 - символ '[', 93 - ']'
  35.     {                
  36.       counter2++;
  37.     }
  38.     else
  39.     {
  40.       if(c == 93)
  41.       {
  42.         if(counter2 > 0)
  43.         {
  44.           counter2--;
  45.         }
  46.         else
  47.         {
  48.           printf("Dizbalance.\n");
  49.           return 0;
  50.         }
  51.       }
  52.     }
  53.    
  54.     //
  55.     if(c == 60) // 60 - символ '<', 62 - '>'
  56.     {                
  57.       counter3++;
  58.     }
  59.     else
  60.     {
  61.       if(c == 62)
  62.       {
  63.         if(counter3 > 0)
  64.         {
  65.           counter3--;
  66.         }
  67.         else
  68.         {
  69.           printf("Dizbalance.\n");
  70.           return 0;
  71.         }
  72.       }
  73.     }
  74.    
  75.     ///
  76.     if(c == 123) // 123 - символ '{', 125 - '}'
  77.     {                
  78.       counter4++;
  79.     }
  80.     else
  81.     {
  82.       if(c == 125)
  83.       {
  84.         if(counter4 > 0)
  85.         {
  86.           counter4--;
  87.         }
  88.         else
  89.         {
  90.           printf("Dizbalance.\n");
  91.           return 0;
  92.         }
  93.       }
  94.     }
  95.    
  96.     s--;
  97.   }
  98.   if(counter1 == 0 && counter2 == 0 && counter3 == 0 && counter4 == 0) printf("Balance\n");
  99.   else printf("Dizbalance");
  100.   return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement