-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmr_robot_0.cpp
54 lines (50 loc) · 970 Bytes
/
mr_robot_0.cpp
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
/**
Mr. Robot - s02e03 57:01
Potential source:
- https://www.modules.napier.ac.uk/Module.aspx?ID=set07109
*/
void StackLinkedList::push(NODE *n)
{
if (front == NULL)
{
front = n;
back = n;
}
else {
front->P = n;
n->N = front;
front = n;
}
}
NODE* StackLinkedList::pop()
{
NODE *temp;
if (front == NULL )//no nodes
return NULL;
else if (back->P == NULL)//there is only one node
{
NODE * temp2 = front;
temp = temp2;
front = NULL;
delete temp2;
return temp;
}
else//there are more than one node
{
NODE *temp2 = front;
temp = temp2;
front = front->P;
front->N = NULL;
delete temp2;
return temp;
}
}
void StackLinkedList::destroyList()
{
while(front != NULL)
{
NODE *temp = front;
front = front->N;
delete temp;
}
}