Sie sind auf Seite 1von 3

#i

ncl
ude<st
dio.
h>

#i
ncl
ude<st
dli
b.h>

i
ntst
ack[
20]
,
max=20,
top=-
1;

v
oidpush(
intel
e)

i
f(
top==max-
1)

pr
int
f("
stackf
ull
")
;

el
se

t
op++;

st
ack[
top]
=el
e;

v
oidpop(
)

i
f(
top==-
1)

pr
int
f("
stackempt
y")
;

el
se

{
pr
int
f("
poppedel
ementi
s:%d\
n",
stack[
top]
);

t
op-
-;

v
oiddi
spl
ay(
)

i
nti
;

pr
int
f("
Cont
ent
sofst
ack\
n")
;

f
or(
i=t
op;
i
>=0;
i
--)

pr
int
f("
%d\
n",
stack[
i]
);

mai
n()

i
ntch,
el
e;

whi
l
e(1)

pr
int
f("
Ent
ery
ourchoi
ce\
n1.
push\
n2.
pop\
n3.
displ
ay\
n4.
exi
t\
n")
;

scanf
("%d"
,&ch)
;

swi
tch(
ch)

case1:
pr
int
f("
ent
ert
heel
ement
");

scanf
("%d"
,&el
e);

push(
ele)
;

br
eak;

case2:

pop(
);

br
eak;

case3:

di
spl
ay(
);

br
eak;

case4:

exi
t(
0);

Das könnte Ihnen auch gefallen