https://pastein.ru/t/Ii

  скопируйте уникальную ссылку для отправки


#include <iostream>
using namespace std;
 
int main()
{
    string a;
    cin >> a;
    int c=0;                 
    if(a[0] != '(' || a[a.length() - 1] != ')')
    {
            printf("ERROR\n");
            system("pause");
            return 0;
            }
    for(int i=0; i <= a.length(); i++)
    {
            if(a[i]=='(')
                   c++; 
                   cout<<"(= "   <<c;     
            else if(a[i]==')')
                   c--;   
                   c++; 
                   cout<<")= "   <<c;
            else if(c<0)
                   break;      
            else if(a[i]=='{')
                   c=c+2;  
                   c++; 
                   cout<<"{= "   <<c;       
            else if(a[i]=='}')
                   c=c-2;  
                   c++; 
                   cout<<"}= "   <<c;        
            else if(c<0)
                   break;         
            else if(a[i]=='[')
                   c=c+3;          
                   c++; 
                   cout<<"[= "   <<c;
            else if(a[i]==']')
                   c=c-3;           
                   c++; 
                   cout<<"]= "   <<c;
             else if(c<0)
                   break;       
            }
    if(c!=0)
            printf("ERROR!!!\n");
    else
        printf("Vse norm\n");
    system("pause");
    return 0;
}