Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <fstream>
  2. #include <stack>
  3.  
  4. using std::ifstream;
  5. using std::ofstream;
  6. using std::stack;
  7. using std::max;
  8.  
  9. stack <bool> S;
  10. int main (void) {
  11. ifstream fin ("paranteze2.in");
  12. ofstream fout ("paranteze2.out");
  13. char x;
  14. int _max=0;
  15. while (fin >> x)
  16. if (x=='(') {
  17. S.push(1);
  18. _max=max(_max, (int)S.size());
  19. }
  20. else
  21. S.pop();
  22. fout << _max;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement