通过对堆栈S操作:Push(S,1),Push(S,2),Pop(S),Push(S,3),Pop(S),Pop(S)。输出的序列为:123。()
举一反三
- 写出下列程序段的输出结果(栈的元素类型为char)。 void main(){ Stack S; char x,y; InitStack(S); x= ‘c’; y= ‘k’; Push(S,x); Push(S, ‘a’); Push(S,y); Pop(S,x); Push(S, ‘t’); Push(S,x); Pop(S,x); Push(S, ‘s’); while(!StackEmpty(S)) { Pop(S,y); printf(y); } printf(x); }
- 经过下列栈的运算后,SEmpty(s)的值是。InitStack(s);Push(s,a);Push(s,b);Pop(s,x);Pop(s,x);
- 对一个初始为空的栈s执行操作push(s,5),push(s,2),push(s,4),pop(s,x),getTop(s,x)后,x的值应是。
- 对一个初始为空的栈s执行操作Push(s,5), Push(s,2), Push(s,4), Pop(s,x), getTop(s,x)后,得到的值应是 。
- 对一个初始值为空的栈S,执行操作:Push(S,5),Push(S,2),Push(S,4),Pop(S,X),ReadTop(S,X)后,X的值应是