代码:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int date = 0;
int arr[32] = { 0 };
scanf("%d",&date);
printf("\n");
int i = 0;
for (i=31;i>=0;i--)//算法,算一个数的二进制序列;
{
arr[i] = date % 2;//利用数组接收这个二进制序列,正常顺序;
//例如 11——00000000 00000000 00000000 00001011 ;
date = date / 2;
}
printf("奇数位二进制序列为:");
for (i =1; i <32; i += 2)//打印奇数位数列
{
printf("%d",arr[i]);
}
printf("\n");
printf("偶数位二进制序列为:");
for (i =0; i < 32; i += 2)//打印偶数位数列
{
printf("%d", arr[i]);
}
return 0;
}
![](https://i-blog.csdnimg.cn/blog_migrate/918dbae5aab131e94288708fd72849bb.png)