/* Program extracts from Chapter 2 of
   "Data Structures and Program Design in C++"
   by Robert L. Kruse and Alexander J. Ryba
   Copyright (C) 1999 by Prentice-Hall, Inc.  All rights reserved.
   Extracts from this file may be used in the construction of other programs,
   but this code will not compile or execute as given here. */


// Section 2.1:

#include "utility.h"
#include "stack.h"

#include <iostream>
//#include <stack>

using namespace std;

void main()
/*
Pre:   The user supplies an integer n and n decimal numbers.
Post:  The numbers are printed in reverse order.
Uses:  The STL class stack and its methods
*/

{
   int n;
   double item;
   //Stack <double> numbers;  //  declares and initializes a stack of numbers

   Stack<double> numbers;

   cout << " Type in an integer n followed by n decimal numbers." << endl
        << " The numbers will be printed in reverse order." << endl;
   cin  >> n;

   for (int i = 0; i < n; i++) {
      cin >> item;
      numbers.push(item);
   }

   cout << endl << endl;
   while (!numbers.empty()) 
   {
	  numbers.top(item);
      cout << item << " ";
      numbers.pop();
   }
   cout << endl;
   numbers.clear();
}



