36 lines
648 B
C++
36 lines
648 B
C++
|
#include <iostream>
|
||
|
#include "Stack.hh"
|
||
|
|
||
|
/*
|
||
|
* Dynamically Sized Stack Implementation
|
||
|
*/
|
||
|
using namespace std ;
|
||
|
|
||
|
int main() {
|
||
|
Stack s(10) ;// initialize Stack
|
||
|
|
||
|
// Write doubles into Stack
|
||
|
int i ;
|
||
|
for (i=0 ; i<15 ; i++) {
|
||
|
cout << "pushing value " << i*i << " in stack" << endl ;
|
||
|
s.push(i*i) ;
|
||
|
}
|
||
|
|
||
|
// Count doubles in fifo
|
||
|
cout << s.nitems() << " value in stack" << endl ;
|
||
|
|
||
|
cout << "Inspect the FIFO" << endl;
|
||
|
s.inspect();
|
||
|
|
||
|
|
||
|
// Read doubles back from fifo
|
||
|
while (!s.empty()) {
|
||
|
double val = s.pop() ;
|
||
|
cout << "popping value " << val << " from stack" << endl ;
|
||
|
}
|
||
|
|
||
|
cout << "Inspect the FIFO" << endl;
|
||
|
s.inspect();
|
||
|
return 0 ;
|
||
|
}
|