求助,栈的输入
程序代码:
#include<stdio.h> #include<math.h> #include<stdlib.h> //存储数据 typedef struct { int situ; int number; int time; }SElemtype; //栈 typedef struct { SElemtype *base; SElemtype *top; int stacksize; }SqStack; //创建栈 void InitStack(SqStack &s,int i) { s.base= (SElemtype*) malloc(i*sizeof(SElemtype)); s.top=s.base; if(!s.top) exit(0); s.stacksize=i; } //插入元素 void push(SqStack &s,SElemtype e) { *s.top=e; s.top++; } void main() { int max,i=1; SElemtype e; SqStack s; scanf("%d",&max); scanf("%d %d %d",&e.number,&e.situ,&e.time); InitStack(s,max); while(e.number!=0) //当number=0结束 { if(i<=max) push(s, e); i=i+1; scanf("%d %d %d",e.number,e.situ,e.time); } }
编译没错,就是执行不对