forked from FaridaAdham/InfixToPostfixConversion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
79 lines (73 loc) · 1.02 KB
/
stack.c
File metadata and controls
79 lines (73 loc) · 1.02 KB
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
#include "stack.h"
void initialize(stack *s)
{
s->top=0;
}
int isempty(stack *s)
{
if(s->top==0)
return 1;
else
return 0;
}
int isfull(stack *s)
{
if(s->top==100)
return 1;
else
return 0;
}
void push(stack *s,char value)
{
s->items[s->top]=value;
s->top++;
}
char pop(stack *s)
{
char val;
s->top--;
val=s->items[s->top];
return val;
}
char top(stack *s)
{
char x=pop(s);
push(s,x);
return x;
}
void initialize1(stack1 *s)
{
s->top=0;
}
int isempty1(stack1 *s)
{
if(s->top==0)
return 1;
else
return 0;
}
int isfull1(stack1 *s)
{
if(s->top==100)
return 1;
else
return 0;
}
void push1(stack1 *s,float value)
{
s->num[s->top]=value;
s->top++;
}
float pop1(stack1 *s)
{
float val;
s->top--;
val=s->num[s->top];
return val;
}
float top1(stack1 *s)
{
float x=pop1(s);
push(s,x);
return x;
}