nicuvlad76

Untitled

Feb 11th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. ifstream fin("paranteze1.in");
  7. ofstream fout("paranteze1.out");
  8.  
  9. int n;
  10. char s[256];
  11.  
  12. int main()
  13. {
  14. fin >> n;
  15. for(int k = 1 ; k <= n ; k ++)
  16. {
  17. fin >> s;
  18. int ok = 1;
  19. int nivel = 0;
  20. for(int i = 0 ; s[i] && ok ; i ++)
  21. if(s[i] == '(')
  22. nivel ++;
  23. else
  24. if(nivel > 0)
  25. nivel --;
  26. else
  27. ok = 0;
  28. if(nivel > 0)
  29. ok = 0;
  30. fout << ok << "\n";
  31. }
  32. }
Add Comment
Please, Sign In to add comment