回复 5楼 ray李锐
#include<stdio.h>#include<malloc.h>
#define OK 1
#define ERROR 0
#define OVERFLOW -1
#define STACK_INIT_SIZE 100
#define STACKINCERMENT 10
typedef int SElemType;
typedef int Status;
typedef struct
{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
//创建一个空栈;
Status InitStack(SqStack &S)
{
S.base=(SElemType *)malloc(STACK_INIT_SIZE * sizeof(SElemType));
if(!S.base)
exit(OVERFLOW);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE ;
return OK;
}//InitStack
//插入操作
Status Push(SqStack &S,SElemType e)
{
if(S.top-S.base>=S.stacksize)
{
S.base=(SElemType*)realloc(S.base,(S.stacksize+STACKINCERMENT)*sizeof(SElemType));
if(!S.base)
exit(OVERFLOW);
S.top=S.base+S.stacksize;
S.stacksize+=STACKINCERMENT; //STACKINCERMENT你应该写错了
}
*S.top++=e;
return OK;
}//Push
//出栈
Status Pop(SqStack &S,SElemType &e)
{
if(S.top==S.base )return ERROR;
e=*--S.top;
return OK;
}//Pop
Status StackEmpty(SqStack &S)//是否是空栈
{
if(S.base==S.top)
return OK;
else
return ERROR;
}
void conversion()
{ SqStack S; //没有定义S
int N;
int e; //没有定义e
InitStack(S);
scanf("%d",&N); //漏了取值符号
while (N)
{
Push(S,N%8);
N=N/8;
}
while (!StackEmpty(S)) //输入格式错误,且漏了S
{
Pop(S,e);
printf("%d",e);
}
}//conversion;
int main()
{
conversion(); //漏分号
return OK;
}
很多基本的语法错了