Subscribe Us

Responsive Advertisement

Advertisement

beecrowd | 1068 solution in cpp

 

beecrowd | 1068 Parenthesis Balance I solution in cpp

by ujjal roy



#include<bits/stdc++.h>

using namespace std;

main()

{

    string s;

    int i;

    while(cin>>s)

    {

   int c=0;

   for(i=0;i<s.size();i++)

   {

       if(s[i]=='(') c++;

       else if(s[i]==')')

       {

           c--;

       }

       if(c<0) break;

   }

        if(c==0) cout<<"correct"<<endl;

        else cout<<"incorrect"<<endl;

    }

}


Post a Comment

0 Comments