-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1StackUsingArray.c
More file actions
59 lines (53 loc) · 860 Bytes
/
Copy path1StackUsingArray.c
File metadata and controls
59 lines (53 loc) · 860 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
53
54
55
56
57
58
59
# include < stdio .h >
# include < stdbool .h >
# include < stdlib .h >
typedef struct {
int arr [10];
} Stack ;
Stack s ;
int top = -1;
void push ( int n ) {
if( top < 9) {
s . arr [++ top ] = n ;
}
}
int pop () {
int temp ;
if( top == -1) {
return -1;
}
else {
temp = s . arr [ top - -];
return temp ;
}
}
bool isEmpty () {
if( top == -1)
return true ;
else
return false ;
}
bool isFull () {
if( top == 9)
return true ;
else
return false ;
}
int main () {
int q , choice , n ;
scanf ("%d", & q ) ;
while (q - -) {
scanf ("%d%d", & choice , & n );
switch ( choice ) {
case 0: push ( n ) ;
break ;
case 1: printf ("%d\n", pop () ) ;
break ;
case 2: printf ("%d\n", isEmpty () ) ;
break ;
case 3: printf ("%d\n", isFull () ) ;
break ;
}
}
return 0;
}