Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct Stiva
- {
- int a[1001], top;
- void Init()
- {top = -1;}
- int Empty()
- {
- if(top == -1) return 1;
- return 0;
- }
- void Push(int x)
- {a[++top] = x;}
- void Pop()
- {if(!Empty()) top--;}
- int Top()
- {return a[top];}
- };
- int main()
- {
- char s[1001], i;
- Stiva st;
- ifstream fin("paranteze.in");
- fin >> s;
- fin.close();
- for(i = 0; s[i] != 0; i++)
- {
- if(s[i] == '(')
- st.Push(i);
- else
- {
- cout << st.Top() << "\n";
- st.Pop();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement