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

代码:

#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# 

参考链接:
https://blog.csdn.net/xzongyuan/article/details/28889063

你可能感兴趣的:(C/C++)