刚学数据结构 顺序栈编写进制转换 帮帮忙找找哪里错
/*54.h*/#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define StackMax 50;
typedef int StackElementType;
typedef struct
{
StackElementType elem[StackMax];
int top;
}SeqStack;
void InitStack(SeqStack *s)
{
s->top=-1;
}
int Push(SeqStack *s,StackElementType x)
{
if(s->top==StackMax-1)
return 0;
s->top++;
s->elem[s->top]=x;
return 1;
}
int Pop(SeqStack *s,StackElementType *x)
{
if(s->top==-1)
return 0;
else
{
*x=s->elem[s->top];
s->top--;
return 1;
}
}
int GetTop(SeqStack *s,StackElementType *x)
{
if(s->top==-1)
return 0;
else
{
*x=s->elem[s->top];
return 1;
}
}
int IsEmpty(SeqStack *s)
{
if(s->top==-1)
return 1;
else
return 0;
}
int IsFull(SeqStack *s)
{
if(s->top==StackMax-1)
return 1;
else
return 0;
}
/*54.c*/
#include <stdio.h>
#include "54.h"
void main()
{
int x,n,y,z;
SeqStack s;
InitStack(s);
printf("输入十进制整数:");
scanf("%d",&n);
printf("输入转换进制:");
scanf("%d",&y);
while(n!=0)
{
x=n%y;
n=n/y;
Push(s,x);
}
while(IsEmpty(s))
{
Pop(s,z);
printf("%d",*z);
}
printf("\n");
}