forked from super30admin/PreCourse-1
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise_2.cpp
More file actions
Latest commit
52 lines (41 loc) · 867 Bytes
/
Copy pathExercise_2.cpp
File metadata and controls
52 lines (41 loc) · 867 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
#include<bits/stdc++.h>
usingnamespacestd;
// A structure to represent a stack
classStackNode {
public:
int data;
StackNode* next;
};
StackNode* newNode(int data)
{
StackNode* stackNode = newStackNode();
stackNode->data = data;
stackNode->next = NULL;
return stackNode;
}
intisEmpty(StackNode* root)
{
//Your code here
}
voidpush(StackNode** root, int data)
{
//Your code here
}
intpop(StackNode** root)
{
//Your code here
}
intpeek(StackNode* root)
{
//Your code here
}
intmain()
{
StackNode* root = NULL;
push(&root, 10);
push(&root, 20);
push(&root, 30);
cout << pop(&root) << " popped from stack\n";
cout << "Top element is " << peek(root) << endl;
return0;
}