#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
void print_num(unsigned int n)
{
int count = 0;
int a[32] = { 0 };
int i = 0;
while (n)
{
a[i++] = n % 2;
n = n / 2;
count++;
}
printf("奇数序列\n");
for (i = count; i >= 0; i = i - 2)
{
printf("%d", a[i]);
}
printf("\n");
printf("偶数序列\n");
for (i = count - 1; i >= 0; i = i - 2)
{
printf("%d", a[i]);
}
printf("\n");
}
int main()
{
int n = 0;
printf("获取一个二进制序列中所以得偶数位和奇数位,分别输出二进制序列:\n");
printf("请输入一个数\n");
scanf("%d", &n);
print_num(n);
system("pause");
return 0;
}