Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ///848
- ifstream fin("paranteze1.in");
- ofstream fout("paranteze1.out");
- char st[300];
- int n;
- int main() {
- fin>>n;
- for(int k=1;k<=n;k++)
- {
- fin>>st;
- int ok=1;///pp ca este corect parantezata
- int top=0;
- for(int i=0; st[i] && ok==1 ;i++)
- if(st[i]=='(') top++;///push=adugare
- else
- if(top>0) ///stiva vida
- top--; ///pop= stergere
- else
- ok=0; ///daca incepe cu ')'
- if(top>0)ok=0;///mai sunt perente deschise nesterse
- fout<<ok<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement