北理工数据结构作业2.docVIP

  • 91
  • 0
  • 约7.11千字
  • 约 10页
  • 2016-01-08 发布于安徽
  • 举报
第三章作业 写出下列程序段的输出结果。 viod 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); } 答:stack 简述下列算法的功能(栈的元素类型SElemType为int)。 (1)Ststus algo1(Stack S) { int I, n, A[255]; n=0; while ( ! StackEmpty(S) ) { n++; Pop(S, A[n]); } for ( i=1; i=n; i++ ) Push(S, A[n]); } 答:实现栈中元素的逆置 (2)Status algo2(Stack S, int e) { Stack T; int d; InitSta

文档评论(0)

1亿VIP精品文档

相关文档