Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int top = -1;
  5. int a[6];
  6. void tops()
  7. {
  8. top++;
  9. }
  10.  
  11. void push(int x)
  12. {
  13. tops();
  14. a[top] = x;
  15.  
  16. }
  17. void pop()
  18. {
  19. top--;
  20. }
  21. void print()
  22. {
  23. cout << "Stack Content = " << a[top] << " top = " << top << "\n";
  24. }
  25.  
  26. int main()
  27. {
  28. push(15); print();
  29. push(25); print();
  30. push(35); print();
  31. push(45); print();
  32. pop(); print();
  33. push(65);print();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement