#define MAX 6int push(int s[],int top,int x){ if(top==MAX) cout<<"over"; else s[top++]=x; return top;}int gettop(int s[],int top){return s[--top];} int pop(int s[],int pop) {if(top==0)cout<<"under"; else top--;return top; } void main() { int s[6]; int x,top=0;cin>>x; while(x!=0) {top=push(s,top,x); cin>>x;} while(top>0) {x=gettop(s,top); cout<<x<<" "; top=pop(s,top);} }这个程序有6个错误,请高手帮助我解决一下,谢谢.
热心网友
首先,你没有说程序用途,所以我不知道你出了什么逻辑错误,就语法错误来看,你没有包头文件,在程序开始加上:#include using namespace std;还有就是你的pop函数中top变量没定义,我看是不是你把参数表弄错了?把参数表的pop改为top,就没语法错误了……改后的代码:#include using namespace std;#define MAX 6int push(int s[],int top,int x){if(top==MAX)coutx;while(x!=0){top=push(s,top,x);cinx;}while(top0){x=gettop(s,top);cout<