dropOutStack.cpp 429 B

1234567891011121314151617181920212223242526
  1. #include "stack.h"
  2. int main() {
  3. stack myStack;
  4. stack_init(myStack);
  5. int item;
  6. // Demonstrate the dropout
  7. for (int c = 0; c < 15; ++c) {
  8. cout << "Enter a number to the stack: ";
  9. cin >> item;
  10. stack_push(myStack, item);
  11. stack_toString(myStack);
  12. }
  13. cout << endl;
  14. // Demonstrate an empty collection exception
  15. for (int c = 0; c < 11; ++c) {
  16. stack_pop(myStack);
  17. stack_toString(myStack);
  18. }
  19. return (0);
  20. }