forked from krishna14kant/Data-Structures-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabc_123
64 lines (61 loc) · 1.04 KB
/
abc_123
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
import java.util.*;
class Repeat
{
int st[]=new int[100];
int capacity;
int f;
int r;
Repeat(int m)
{
capacity=m;
f=r=-1;
}
void pushvalue(int v)
{
if(r==capacity-1)
System.out.println("OVERFLOW");
else
{
if(f==-1 && r==-1)
{
f=0;r=0;
}
else
{
r=r+1;
st[r]=v;
}
}
}
int popvalue()
{
int v;
if(r==-1 && f==-1)
return(-9999);
else
{
v=st[f];
if(f==r)
{
f=-1;
r=-1;
}
else
f=f+1;
return(v);
}
}
void dispaly()
{
if(f==-1 && r==-1)
System.out.println("List underflow");
else
{
System.out.println("element of the list");
for(int i=f;i<=r;i++)
{
System.out.println(st[i]);
}
}
}
}