-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstackLinkedList.cpp
88 lines (85 loc) · 1.19 KB
/
stackLinkedList.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include<bits/stdc++.h>
#define MAX 101
using namespace std;
int stack[MAX];
int top = -1;
void push(int x)
{
if(top == MAX)
{
cout<<"stack full";
return;
}
stack[++top] = x;
}
void pop()
{
if(top == -1)
{
cout<<"stack empty";
return;
}
top--;
}
int top()
{
return stack[top];
}
void print()
{
int i;
for(i=0; i<=top; i++)
cout<<stack[i];
}
void push(int x)
{
Node* temp = new Node();
temp->data = data;
temp->next = NULL;
top = temp;
}
void pop()
{
Node* temp;
if(top == NULL)
return;
temp = top;
top = top->link;
free(temp);
}
void top()
{
if(top == NULL)
returm;
cout<<top->data;
}
struct Node* front = NULL;
struct Node* rear = NULL;
void enquue(int x)
{
node* temp =new Node();
temp->data = x;
temp->next = NULL;
if(front == NULL && rear == NULL)
{
front = rear = temp;
return;
}
rear->next = temp;
rear = temp;
}
void deque( int x)
{
if(front == NULL)
return;
if(front == rear)
{
front =rear =NULL;
}
front = front->next;
free(temp);
}
int main()
{
return 0;
}