Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- string s;
- int x;
- stack<int> my;
- while(cin >> s){
- if(s == "exit"){
- cout << "bye" << endl;
- break;
- }
- if(s == "push"){
- cin >> x;
- my.push(x);
- cout << "ok" << endl;
- }
- if(s == "pop"){
- cout << my.top() << endl;
- my.pop();
- }
- if(s == "back"){
- cout << my.top() << endl;
- }
- if(s == "size"){
- cout << my.size() << endl;
- }
- if(s == "clear"){
- while(!my.empty()){
- my.pop();
- }
- cout << "ok" << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement