• 请问大神们这个代码运行后没有结果直接结束是为什么?
  • 其他开发语言

#include
#define max 100
typedef struct saqstack
{
int elem[max];
int top;
}saqstack;
int push(saqstack *s,int a)
{
if(s->top==max-1)
return 0;
else
{
s->top=s->top+1; 
s->elem[s->top]=a;
return 1;}
}
int cs(saqstack *s)
{
s->top=-1;
}
int pop(saqstack *s,int *x)
{
if(s->top==-1)
return 0;
else
{
*x=s->elem[s->top];
s->top=s->top-1;
return 1;}

}
int print(saqstack *s)
{
printf("%d",s->elem[s->top]);
return 0;
}
int main()
{
saqstack *s;
int *x;
cs(s);
printf("pelase input the number;");
int a;
scanf("%d",&a);
push(s,a);
print(s);
push(s,1);
print(s);
pop(s,x);
print(s);
return 0;
}


  • TIMI    2019-11-29 15:41:07
  • 阅读 883    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信