/*
============================================================================
Name : decima_to_binary.c
Author :
Version :
Copyright : Your copyright notice
Description : 把输入的十进制数,除以2的余数,放在数组中。最后倒序输出。
============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int n,j;
int a[16] = {0};
printf("please input a number :");
scanf("%d", &n);
for(int m=0; m<=15; ++m){
a[m] = n % 2;
j = n / 2;
n = j;
}
for(int i = 15; i > -1; --i ){
printf("%d ",a[i]);
if(i % 4 == 0){
printf(" ");
}
}
return EXIT_SUCCESS;
}
please input a number :99
0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1