C语言:以二进制方式打印数据

时间:2024-11-12 10:32:22

代码:

#include <>
#include <>
#include <>
void decToBin(int num)
{
	if(num>0)
		{
			decToBin(num/2);
			printf("%d",num%2);
		}
}

int main()
{
	int num = 1234567891;
	decToBin(num);
	printf("\n");
	return 0;
}

运行结果:

root@ubuntu:/mnt/hgfs/Ubuntu12.04-share# ./test
1001001100101100000001011010011
root@ubuntu:/mnt/hgfs/Ubuntu12.04-share# 

参考链接:
/xzongyuan/article/details/28889063

相关文章