#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#define MAXSIZE 100
typedef struct
{
int data[MAXSIZE];
int top;
}Se,*Pe;
Pe begin();
void ru(Pe S,int x);
Pe zhuan(int m,int n);
void xiao(Pe *S);
void chu(Pe S);
int main()
{
Pe S;
int x,y;
printf("输入要转换的十进制数和要转换的进制:\n");
scanf("%d %d",&x,&y);
S=zhuan(x,y);
chu(S);
xiao(&S);
}
Pe begin()
{
Pe S;
S=(Pe)malloc(sizeof(Se));
if(S)
S->top=-1;
return S;
}
void ru(Pe S,int x)
{
S->top++;
S->data[S->top]=x;
}
Pe zhuan(int m,int n)
{
Pe S;
S=begin();
int k;
while(m!=0)
{
k=m%n;
ru(S,k);
m=m/n;
}
return S;
}
void xiao(Pe *S)
{
if(*S)
free(*S);
*S=NULL;
}
void chu(Pe S)
{
while(S->top!=-1)
{
printf("%d",S->data[S->top]);
S->top--;
}
}