『代码』··By/蜜汁炒酸奶

进制转换

/*
功能:进制转换
日期:2013-06-08
*/
#include<stdio.h>
#include<stdlib.h>
void convertHex (int x);

int main(void)
{
	int num;

	printf("请输入一个十进制数字:");
	scanf("%d",&num);

	printf("%d的二进制为:",num);
	convertHex(num);

	printf("n");
	system("pause");
}

void convertHex (int x)
{   int remainder;
   	 if (x==0)
	{

	  return;
	}

    remainder = x % 2;
	 x = x / 2;
	 convertHex(x);
	printf("%d",remainder);

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

预览
Loading comments...
0 条评论

暂无数据

example
预览