-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_stack1.cpp
More file actions
71 lines (52 loc) · 1.34 KB
/
Copy pathtest_stack1.cpp
File metadata and controls
71 lines (52 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <cstdlib>
#include "stack.h"
using namespace std;
using namespace cop4530;
int main() {
Stack<int> intstk;
cout << "inserting 10 elements" << endl;
for (unsigned int i = 0; i < 10; ++i)
intstk.push(i);
cout << "Size: " << intstk.size() << endl;
cout << "elements: " << intstk << endl;
cout << "emptying the stack" << endl;
while (!intstk.empty()) {
cout << intstk.top() << " ";
intstk.pop();
}
cout << endl;
cout << "Size: " << intstk.size() << endl;
cout << "inserting 10 elements" << endl;
for (unsigned int i = 0; i < 10; ++i)
intstk.push(i);
Stack<int> intstk1(intstk);
Stack<int> intstk2;
intstk2 = intstk;
cout << intstk << endl;
cout << intstk1 << endl;
cout << intstk2 << endl;
intstk.push(100);
if (intstk2 <= intstk)
cout << "unchanged stack smaller." << endl;
else
cout << "ERROR: longer stack is smaller " << endl;
if (intstk1 == intstk2)
cout << "Equal stacks" << endl;
else
cout << "ERROR: stacks are not equal" << endl;
intstk1.pop();
#if 1
if (intstk1 == intstk2)
cout << "Error: equal stacks" << endl;
else
cout << "Stacks are not equal" << endl;
if (intstk1 <= intstk2)
cout << "intstk1 is less than or equal to intstk2" << endl;
else
cout << "ERROR: wrong comparision" << endl;
#endif
cout << intstk1 << endl;
return(EXIT_SUCCESS);
//return 0;
}