Introduction - If you have any usage issues, please Google them yourself
#include <stdio.h>
#include <stdlib.h>
//输入十进制数N和转化的进制数M
void trans(int n,int m)
{ char str[100] int i
for(i=0 n>0 i++)
{if (n m<10) {str[i]=n m+ 0 }
else {str[i]=n m-10+ A }
n=n/m
}
for(n=i n>0 n--){printf(" c",str[n-1]) }
}
void main()
{ int m,n,x char ch
printf("给定进制 M---")
scanf(" d",&m)
loop:
printf("给定一个 d 进制的数 X---",m)
fflush(stdin) //一个M进制的数X转10进制
for(x=0 )
{ ch=getchar()
if(ch>= 0 && ch<= 9 ) { n=ch- 0 }
else if(ch>= a && ch<= z ) { n=ch- a +10 }
else if(ch>= A && ch<= Z ) { n=ch- A +10 }
else { break }
if(n>=m){goto loop }
x=x*m+n
}
printf("转换成 10 进制的数为--- d\n",x)
printf("给定要转换成的进制 N---")
scanf(" d",&m)
printf("转换成 d 进制后的结果---",m)
trans(x,m)
printf("\n")
}