Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack>
- using namespace std;
- void workWithStack (){
- stack<char> simpleStack(100);
- string justInput;
- cin >> justInput;
- char num;
- while (justInput != "exit") {
- if (justInput == "push") {
- cin >> num;
- simpleStack.push(num);
- cout << "ok" << endl;
- } else if (justInput == "pop") {
- simpleStack.peek(1);
- simpleStack.pop();
- } else if (justInput == "back") {
- simpleStack.peek(1);
- } else if (justInput == "size") {
- simpleStack.size();
- } else if (justInput == "clear") {
- simpleStack.clear();
- cout << "ok" << endl;
- }
- cin >> justInput;
- }
- cout << "bye";
- }
- int main()
- {
- workWithStack();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement