#include<stdio.h>
#include<stdlib.h>
#define Maxsize 100
typedef int SelmType;
typedef struct{
SelmType stack[100];
int top;
}SqStack;
void InitStack(SqStack *S) {
S->top=0;
}
int StackEmpty(SqStack *S) {
if(S->top==0)
return 1;
else
return 0;
}
int GetTop(SqStack S,SelmType e) {
if(S.top>0){
e=S.stack[S.top-1];
return e;
}
else
return -1;
}
void Push(SqStack *S,SelmType e){
if((S->top)>100){
printf("Stack overflow");}
else
S->stack[S->top++]=e;
}
void Pop(SqStack *S,SelmType e) {
if(S->top==0){
printf("Stack underflow");}
else
e=S->stack[--S->top];
}
void conver(SelmType e,SelmType n){
int i,L;
int m=e;
SqStack S;
InitStack(&S);
do{
i=e%n;
Push(&S,i);
e/=n;
}while(e);
printf("%d转化成%d进制等于",m,n);
while(S.top!=0){
L=GetTop(S,n);
if(L!=-1){
printf("%d",L);}
S.top--;
}}
int main(){
SelmType i,n;
printf("输入一个十进制");
scanf("%d",&i);
printf("转化为几进制");
scanf("%d",&n);
conver(i,n);
}