c中关于顺序栈操作的一个小程序,求救

来源:百度知道 编辑:UC知道 时间:2024/05/25 06:11:10
recurrence1.c的代码:
#include"stdio.h"
#include "D:\study\dev program\sqstack9.c"

seqstack *a;

main(){
int x,n=0;
INISTACK(a);
printf("\nEnd with -1:");
scanf("%d",&x);
while(x!=-1){
a = PUSH(a,x);
n++;
scanf("%d",&x);
}
printf("n=%d\n",n);
while(EMPTY(a)!=1){
x = POP(a);
printf("%d ",x);
n--;
}
printf("n=%d\n",n);
getchar();
}

sqstack9.c的代码:
/*==================================*/
/* 5 fundary sequence stack operation */
/*==================================*/

#define true 1
#define Null 0

#define MAXSIZE 50
typedef int datatype;
typedef struct{
datatype stack[MAXSIZE];
int top;
}seqstack;

void INISTAC

seqstack *a;

main(){
int x,n=0;
INISTACK(a);
=================================

seqstack *a 没有初始化,INISTACK里
直接操作成员变量S->top = -1;
所以报运行时错。。。

加个
seqstack b;
seqstack *a = &b

鉴定完毕