Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3.  
  4. using namespace std;
  5.  
  6. void workWithStack (){
  7. stack<char> simpleStack(100);
  8. string justInput;
  9. cin >> justInput;
  10. char num;
  11. while (justInput != "exit") {
  12. if (justInput == "push") {
  13. cin >> num;
  14. simpleStack.push(num);
  15. cout << "ok" << endl;
  16. } else if (justInput == "pop") {
  17. simpleStack.peek(1);
  18. simpleStack.pop();
  19. } else if (justInput == "back") {
  20. simpleStack.peek(1);
  21. } else if (justInput == "size") {
  22. simpleStack.size();
  23. } else if (justInput == "clear") {
  24. simpleStack.clear();
  25. cout << "ok" << endl;
  26. }
  27. cin >> justInput;
  28. }
  29. cout << "bye";
  30. }
  31.  
  32. int main()
  33. {
  34. workWithStack();
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement