#include <stdio.h>
#define MAX 20
void convert(int num,int n)
{
int i=0,j=0;
int array[MAX];
while(num!=0)
{
array[i]=num%n;
i++;
j++;
num=num/n;
}
for(i=j-1;i>=0;i--)
printf("%d",array[i]);
printf("\n");
}
int main()
{
int num,n;
printf("enter a number:");
scanf("%d",&num);
printf("which hex you want to convert:");
scanf("%d",&n);
convert(num,n);
return 0;
}
转换为任意进制