Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <string>
- #include <set>
- #include <stack>
- #include <queue>
- #include <deque>
- using namespace std;
- #define TASK "stack"
- int a[2000000], fr = 0;
- void push(int x) {
- a[fr] = x;
- fr++;
- }
- void pop() {
- fr--;
- }
- int top() {
- return a[fr - 1];
- }
- int main() {
- #ifdef _DEBUG
- freopen("debug.in", "r", stdin);
- freopen("debug.out", "w", stdout);
- #else
- freopen(TASK".in", "r", stdin);
- freopen(TASK".out", "w", stdout);
- #endif // _DEBUG
- int m, t;
- char c;
- cin >> m;
- for (int i = 0; i < m; i++) {
- cin >> c;
- if (c == '-') {
- cout << top() << "\n";
- pop();
- }
- else {
- cin >> t;
- push(t);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement