1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex3.1/main.cpp

37 lines
721 B
C++
Raw Normal View History

2019-12-03 12:05:49 +01:00
#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 ;
}