36 lines
721 B
C++
36 lines
721 B
C++
#include <iostream>
|
|
#include "Stack.hh"
|
|
|
|
/*
|
|
* Using 100 elements is too much for the default stack
|
|
* But it fails gracefully so when popping it starts from 80
|
|
*/
|
|
using namespace std ;
|
|
|
|
int main() {
|
|
Stack s ;// initialize Stack
|
|
|
|
// Write doubles into Stack
|
|
int i ;
|
|
for (i=0 ; i<100 ; 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 ;
|
|
}
|