#include <stdio.h>
typedef struct {
int data[50];
int top;
}SqStack;
void InitStack(SqStack *s) {
s->top=-1;
}
void Push(SqStack *s,int e) {
if(s->top==49)
printf("满了");
else{
s->top++;
s->data[s->top]=e;
}
}
int empty(SqStack *s){
if(s->top==1)
return 1;
else
return 0;
}
char Pop(SqStack *s)
{
int e;
e=s->data[s->top];
s->top--;
return e;
}
void multi(int a,int b){
int i;
SqStack s;
InitStack(&s);
while(a!=0){
Push(&s,a%b);
a=a/b;
}
printf("结果是");
while(!empty(&s)){
i=Pop(&s);
printf("%d",i);
}
printf("\n");
}
main(){
int a,b;
printf("输入十进制数字");
scanf("%d",&a);
printf("输入进制");
scanf("%d",&b);
printf("转换完的数为");
multi(a,b);
}