#include<stdio.h>
#include<stdlib.h>
void change2(int num)
{
if (num != 0)
{
change2(num / 2);
printf("%d", num % 2); //printf函数在change2函数后,为逆序打印!
}
}
void main()
{
int num=0;
printf("请输入要转换的十进制数: ");
scanf("%d", &num);
printf("转换后的二进制数为: ");
change2(num);
system("pause");
}
转载于:https://www.cnblogs.com/lxf0923/p/4278270.html