2234: DS-模拟题2
金币值:2
定数:9
时间限制:1.000 s
内存限制:128 M
正确:33
提交:64
正确率:51.56% 命题人:
题目描述
下列程序的功能是从键盘上输入10整数依次进栈,从栈顶开始依次输出这个10整数。修改程序,保证运行正确。
#include <stdio.h> typedef struct { int base[10]; /*提交以下部分*/ int top; // ERROR } SqStack; void push(SqStack &s, int e) { s.top=e; // ERROR /*提交结束*/ s.top++; } int main(void) { int i,e; SqStack s; s.top=s.base; for(i=1; i<=10; i++) { scanf("%d",&e); push(s,e); } s.top--; while(s.top>=s.base) { printf("%d ",*s.top); s.top--; } return 0; }
输入格式
10个数
输出格式
见样例
输入样例 复制
1 2 3 4 5 6 7 8 9 10
输出样例 复制
10 9 8 7 6 5 4 3 2 1