文章
145
粉丝
217
获赞
21
访问
84.6k
#include <stdio.h>
void OddCheck(char *s)
{
char *p = s;
while(*p != '\0')
{
int a[8] = {0},i = 7,n = *p,count = 0; //b获取十进制数,count记录1的个数
while(n && i >= 0)
{
if(n % 2 == 1) count++;
a[i] = n%2;
n/=2;
i--;
}
if(count % 2 == 0) a[0] = 1;
for(i = 0; i < 8; i++)
printf("%d",a[i]);
printf("\n");
p++;
}
}
int main()
{
char s[100];
while(gets(s) != NULL)
OddCheck(s);
return 0;
}
登录后发布评论
暂无评论,来抢沙发