求大神帮忙看一下一道c语言的题
我是要16进制换成2进制可否帮忙看一下哪里错了?#include<stdio.h>intc;main(){inta;intb;scanf("%x%x",&a,&b);c=...
我是要16进制换成2进制 可否帮忙看一下哪里错了?
#include<stdio.h>
int c;
main()
{
int a;
int b;
scanf("%x%x",&a,&b);
c=a+b;
}
void printx()
{
if (c<0xf)
switch(c)
{
case 0x0:
printf("0000");
break;
case 0x1:
printf("0001");
break;
case 0x2:
printf("0010");
break;
case 0x3:
printf("0011");
break;
case 0x4:
printf("0100");
break;
case 0x5:
printf("0101");
break;
case 0x6:
printf("0110");
break;
case 0x7:
printf("0111");
break;
case 0x8:
printf("1000");
break;
case 0x9:
printf("1001");
break;
case 0xa:
printf("1010");
break;
case 0xb:
printf("1011");
break;
case 0xc:
printf("1100");
break;
case 0xd:
printf("1101");
break;
case 0xe:
printf("1110");
break;
case 0xf:
printf("1111");
break;
}
if(c/16)
printx(c/16);
} 展开
#include<stdio.h>
int c;
main()
{
int a;
int b;
scanf("%x%x",&a,&b);
c=a+b;
}
void printx()
{
if (c<0xf)
switch(c)
{
case 0x0:
printf("0000");
break;
case 0x1:
printf("0001");
break;
case 0x2:
printf("0010");
break;
case 0x3:
printf("0011");
break;
case 0x4:
printf("0100");
break;
case 0x5:
printf("0101");
break;
case 0x6:
printf("0110");
break;
case 0x7:
printf("0111");
break;
case 0x8:
printf("1000");
break;
case 0x9:
printf("1001");
break;
case 0xa:
printf("1010");
break;
case 0xb:
printf("1011");
break;
case 0xc:
printf("1100");
break;
case 0xd:
printf("1101");
break;
case 0xe:
printf("1110");
break;
case 0xf:
printf("1111");
break;
}
if(c/16)
printx(c/16);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询