Advertisement
Guest User

14

a guest
Oct 13th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <deque>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. deque <int> q1,q2;
  9. char x;
  10. int i(0), k=0;
  11. bool f(0);
  12. while(cin >> x)
  13. {
  14. if (x == '(')
  15. {
  16. q1.push_back(i+1);
  17. f=1;
  18. k++;
  19. }
  20. if (x==')')
  21. {
  22. if (f)
  23. {
  24. q2.push_back(i+1);
  25. f=0;
  26. k--;
  27. }
  28. else
  29. {
  30. q2.push_front(i+1);
  31. k--;
  32. }
  33. }
  34. if(!k)
  35. {
  36. while(!q1.empty())
  37. {
  38. cout << *q1.begin() << ' ' << *q2.begin() << "; ";
  39. q1.pop_front();
  40. q2.pop_front();
  41. }
  42. }
  43. i++;
  44. }
  45. return 0;
  46. }
  47. ///A+(45-K(X)*(C-Y))
  48. /// ()((()()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement