楼上的我替你换成C了。
#include"stdio.h"
int main(void)
{
const char digit[]="0123456789abcdef";
int a[100],m,n,next,i=0;
scanf("%i%i",&m,&n);
while(m!=0){
a[i]=m%n;
++i;
m/=n;}
for (--i;i>=0;--i){
next=a[i];
printf("%c",digit[next]);}
getch();
return 0;
}

深山苦学C语言,终年不见外面世界。