#include\"stdio.h\"
#include\"stdlib.h\"
#include\"math.h\"
typedefstructSTACK{
int*base;
int*top;
intstacksize;
}sqstack;
typedefstructLNode{
intdata;
structLNode*next;
}LNode,*linklist;
sqstackBuild(sqstack*s){
s-base=malloc(100*sizeof(int));
s-top=s-base;
s-stacksize=100;
return*s;
}
intGetTop(sqstack*s,inte){
if(s-top==s-base)
exit(0);
e=*(s-top-1);
returne;
};
voidpush(sqstack*q,inte){
if(q-top-q-base==q-stacksize)
{
q-base=malloc((q-stacksize10)*sizeof(int));
if(!q-base)exit;
q-top=q-baseq-stacksize;
q-stacksize=10;
}
*q-top=e;
}
voidpop(sqstack*q,inte){
if(q-base==q-top)
{
exit;
}
e=*--q-top;
}
main()
{
inta[256];
intn;
inti=0;
intj=0;
inte;
sqstack*S;
Build(S);
S-top=-1;
printf(\"inputn:\");
scanf(\"%d\",
for(i=0;in;i)
{
printf(\"inputa[%d]\",i);
scanf(\"%d\",a);
push(S,a);
}
while(S-base!=S-top)
{
pop(S,e);
printf(\"%d\",e);
}
}
这段代码,编译连接没有问题,但是一运行就出错,类似的程序写了好几个了,都是类似情况,头疼,求教~我的分只有3分了,也给不了,但求好心的有知人士帮忙解答~小弟谢了!
|