/* Filename: reverse.cpp Programmer: Br. David Carlson Date: March 28, 1998 Modified: April 23, 1999 to use an array-based stack. Only the include and the type of the stack object had to be changed. Last Modifed: December 4, 2001 This program prompts the user to enter a sequence of numbers (floats) and then prints them in reverse order. (Change the CTRL z to CTRL d for Linux.) */ #include "arrstack.h" int main(void) { ArrStackClass Stack; ItemType Number, Item; // Change to CTRL d for Linux: cout << "Enter a number (CTRL z to end): "; cin >> Number; while (! cin.fail()) { Stack.Push(Number); // Change to CTRL d for Linux: cout << "Enter another number (CTRL z to end): "; cin >> Number; } if (Stack.Empty()) cout << endl << endl << "Stack is empty" << endl; else { cout << endl << endl << "Numbers in reverse order are:" << endl; while (! Stack.Empty()) { Stack.Pop(Item); cout << Item << endl; } } return 0; }