请教高手,一个简单的栈应用?
程序代码://将一个十进制数转换为八进制数
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#define STACK_INIT_SIZE 100;
#define STACKINCREMENT 10;
typedef struct SqStack{
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_SISE;
return OK;
}
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;
S.top++;
return OK;
}
Status Pop(SqStack &S,int e){//出栈操作
if(S.top==S.base) return ERROR;
S.top--;
e=*S.top;
return OK;
}
void conversasion(){//转换函数
int N,e;
SqStack S;
InitStack(S);
printf("请输入要转换为8进制的10进制数为:",N);
scanf("%d",&N);
while(N){
Push(S,N%8);
N=N/8;
}
while(S.top!=S.base)
Pop(S,e);
printf("%d",e);
}
int main(){
conversation();
return 0;
}









