forked from super30admin/PreCourse-1
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise_1.cpp
More file actions
Latest commit
54 lines (44 loc) · 954 Bytes
/
Copy pathExercise_1.cpp
File metadata and controls
54 lines (44 loc) · 954 Bytes
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
#include<bits/stdc++.h>
usingnamespacestd;
#defineMAX1000
classStack {
//Please read sample.java file before starting.
//Kindly include Time and Space complexity at top of each file
int top;
public:
int a[MAX]; // Maximum size of Stack
Stack() { //Constructor here }
boolpush(int x);
intpop();
intpeek();
boolisEmpty();
};
boolStack::push(int x)
{
//Your code here
//Check Stack overflow as well
}
intStack::pop()
{
//Your code here
//Check Stack Underflow as well
}
intStack::peek()
{
//Your code here
//Check empty condition too
}
boolStack::isEmpty()
{
//Your code here
}
// Driver program to test above functions
intmain()
{
classStack s;
s.push(10);
s.push(20);
s.push(30);
cout << s.pop() << " Popped from stack\n";
return0;
}