关于进制转换的问题,麻烦大侠们给看下问题出在哪了
#include "stdio.h"void convert(int n,int m);
main()
{
int num,b;
printf("Enter the num:");
scanf("%d%d",&num,&b);
convert(num,b);
}
void convert(int n,int m)
{
long a;
int b;
if(b==2||b==8)
{
int x=0,y;
int c[32];
while(a!=0)
{
y=a%b;
c[x++]=y;
a=a/b;
}
while(x>0)
printf("%d",c[--x]);
}
else if(b==16)
{
char s[16][2]={{"0"},{"1"},{"2"},{"3"},{"4"},{"5"},{"6"},{"7"},{"8"},{"9"},{"A"},{"B"},{"C"},{"D"},{"E"},{"F"}};
int k[8],i=0,j,y;
while(a!=0)
{
y=a%16;
a=a/16;
k[i++]=y;
}
for(j=1;j<=i;j++)
printf("%s",s[k[i-j]]);
}
}