本文共 376 字,大约阅读时间需要 1 分钟。
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>#include<stdlib.h>int main(){ int i = 0;int j = 0;int num = 0;int arr[100];int k = 0;scanf("%d", &num);while (num !=0 )//取余动作,直至余数为0{ arr[k]=num % 2;num = num / 2;k++;}i = k;for (k = i - 1; k >= 0;k--)//反向输出二进制数{ printf("%d", arr[k]);}system("pause");return 0;}转载于:https://blog.51cto.com/14239789/2377442