Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <deque>
- using namespace std;
- int main()
- {
- deque <int> q1,q2;
- char x;
- int i(0), k=0;
- bool f(0);
- while(cin >> x)
- {
- if (x == '(')
- {
- q1.push_back(i+1);
- f=1;
- k++;
- }
- if (x==')')
- {
- if (f)
- {
- q2.push_back(i+1);
- f=0;
- k--;
- }
- else
- {
- q2.push_front(i+1);
- k--;
- }
- }
- if(!k)
- {
- while(!q1.empty())
- {
- cout << *q1.begin() << ' ' << *q2.begin() << "; ";
- q1.pop_front();
- q2.pop_front();
- }
- }
- i++;
- }
- return 0;
- }
- ///A+(45-K(X)*(C-Y))
- /// ()((()()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement