[理工] [資結]-96高應
Below are two operations. It is assumed that S is an integer
stack and x,y,and z are integer variables. What is the output?
i) ii)
x:=1; y:=1;
y:=2; clearstack(S);
z:=3; push(S,5);
clearstack(S); push(S,7);
push(S,x); pop(S,x)
push(S,4); x:=x+y;
pop(S,z); pop(S,x);
push(S,y); push(S,x);
push(S,3); push(S,y);
push(S,z); push(S,2);
pop(S,x); pop(S,y);
push(S,4); pop(S,x);
push(S,x); while not emptystack(S) do
while not emptystack(S) do begin
begin pop(S,y);
pop(S,x); writeln(y);
writeln(x); end;
end; writeln('x=',x,'y=',y);
有請高手幫忙
--
→
03/03 12:58,
03/03 12:58
→
03/03 13:03,
03/03 13:03
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.217.48.51
推
03/09 23:42, , 1F
03/09 23:42, 1F
推
03/10 12:18, , 2F
03/10 12:18, 2F