Advertisement
Guest User

Untitled

a guest
Jan 21st, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include "stack.h"
  5.  
  6. using namespace std;
  7.  
  8. template <class Type>
  9. void addItems(Stack<Type> stack);
  10.  
  11. template <class Type>
  12. void removeItems(Stack<Type> stack);
  13.  
  14. int main() {
  15.    
  16.     int max;
  17.    
  18.     int intTmp;
  19.     Stack<int> intStack = Stack<int>();
  20.     max = intStack.getMax();
  21.     cout << "Max = " << max << endl;
  22.  
  23.     addItems(intStack); //---- ???????
  24.  
  25.     cout << endl << "Stack is full! Let's pop() everything:" << endl << endl;
  26.  
  27.     removeItems(intStack); //--- ???????
  28.    
  29.     system("PAUSE");
  30.     return 0;  
  31. }
  32.  
  33. template <class Type>
  34. void addItems(Stack<Type> stack) {
  35.     Type tmp;
  36.     while (!stack.isFull()) {
  37.         cout << "Give a number: ";
  38.         cin >> intTmp;
  39.         stack.push(intTmp);
  40.         cout << "-----" << endl;
  41.         cout << "How many items?: " << stack.getTop() << "/" << stack.getMax() << endl;
  42.         stack.showItems();
  43.         cout << "==========" << endl;
  44.     }
  45. }
  46.  
  47. template <class Type>
  48. void removeItems(Stack<Type> stack) {
  49.     Type tmp;
  50.     cout << "A? " << stack.getTop() << endl;
  51.     while (!stack.isEmpty()) {
  52.         stack.pop(intTmp);
  53.         cout << "Popped(): " << intTmp << endl;
  54.         cout << "-----" << endl;
  55.         cout << "How many items?: " << stack.getTop() << "/" << stack.getMax() << endl;
  56.         stack.showItems();
  57.         cout << "==========" << endl;  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement