数制转换(错在那)
#include<malloc.h>#include<stdio.h>
#define STACK_INIT_SIZE 100
#define STACKINCERMENT 10
#define OK 1
#define OVERFLOW -1
#define ERROR 0
typedef struct{
int *base;
int *top;
int stacksize;}sqstack;
int initstack(sqstack *s)
{ s->base=(int*)malloc(STACK_INIT_SIZE*sizeof(int));
s->top=s->base;
s->stacksize=STACK_INIT_SIZE;
return OK;}
void 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;}
void pop(spstack *s,int *e)
{ if(s->top==s->base)
return ERROR;
*e=*(--s->top);}
main()
{int n,m,e;
initstack(&s);
clrscr();
scanf("%d%d",&n,&m);
while(n){ push(&s,n%m);
n=n/m;}
while(!(s.top==s.base))
{pop(&s,&e);
if(e<=q)
printf("%d",e);
else
printf("%c",e-10+'A');
}
}