栈的使用问题

来源:百度知道 编辑:UC知道 时间:2024/06/10 16:38:04
用栈求逆波兰式。 大虾们帮下忙找找哪里错了
#include "stdio.h"
#define STACK_INIT_SIZE 100;
#define STACKINCREMENT 10;
#define overflow -2;
#include "malloc.h"
#include "stdlib.h"
typedef void Status;
typedef struct{
int *base;
int *top;
int stacksize;
}SqStack;
Status InitStack(SqStack S){
S.base=(int *)malloc(STACK_INIT_SIZE*sizeof(int));
if(!S.base)exit(overflow);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
return;
}

Status Push(SqStack S,int e){
if(S.top-S.base>=S.stacksize){
S.base=(int *)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(int));
if(!S.base)exit(overflow);
S.top=S.base+S.stacksize;
S.stacksize+=STACKINCREMENT;
}
*S.top++=e;
return;
}

Status Pop(SqStack S,int e){
if(S.top==S.base)return;
e=*--S.top;
return;
}
void cal();
char p[100],q[100]; int

楼主有没有试过这么改,把你所有的define的东西都直接用,比如
在你的代码里如果碰到STACK_INIT_SIZE 就换成100,碰到overflow就换成-2,这样就通过。也就是问题出在那
我也不太清楚怎么回事,但是这么改编译可以通过
const int STACK_INIT_SIZE=100;
const int STACKINCREMENT=10;
const int overflow= -2;

C:\Documents and Settings\Administrator\桌面\H1.c(23) : error C2143: syntax error : missing ';' before ')'
C:\Documents and Settings\Administrator\桌面\H1.c(24) : error C2143: syntax error : missing ')' before ';'
C:\Documents and Settings\Administrator\桌面\H1.c(24) : error C2143: syntax error : missing ';' before ')'

before ';'
C:\Documents and Settings\Administrator\桌面\H1.c(15) : error C2059: syntax error : ')'
C:\Documents and Settings\Administrator\桌面\H1.c(23) : error C2143: syntax error : missing ')' before ';'
C:\Documents and Settings\Administrator