#include <stdio.h>
#include <stdlib.h>
int main()
{
short n;
short arr[17];
printf("n=");
scanf("%hd", &n);
printf("the binary number is ");
int i = 0;
while (i < 16)
{
arr[i] = n & 1; //与运算,1的二进制为0000 0000 0000 0001,与运算以后只取n二进制的最低位,用数组保存
n = n >> 1; //n右移一位;
i++;
}
for (i = 15; i >= 0; i--) { // 倒序输出数组
printf("%d", arr[i]);
}
}