#include<stdio.h>
int
main()
{
char
ku[16]={
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
int
zh[32],i=0,w,j;
long
int
b,y;
printf
(
"請輸入一個十進制數,我能幫您把它轉換成2~16任意進制數:\n"
);
scanf
(
"%d"
,&y);
b=y;
printf
(
"請輸入要轉換為的進制:"
);
scanf
(
"%d"
,&w);
printf
(
"\n"
);
do
{
zh[i]=y%w;
i++;
y=y/w;
}
while
(y!=0);
printf
(
"把十進制的%ld轉換為%d進制:"
,b,w);
for
(i--;i>=0;i--)
{
j=zh[i];
printf
(
"%c"
,ku[j]);
}
printf
(
"\n"
);
return
0;
}