#include <stdio.h>
int fun(int a){ int i; int b = 0; for(i = 0;i < 32;i++) {if(i == 0 || i == 31){b += ((a >> i) & 1) << i;}else{b += (((a >> (i - 1)) & 1) ^ ((a >> (i + 1)) & 1)) << i;} } return b;}void rest(int a){int i;int temp; for(i = 31;i >= 0;i--){if ((i + 1) % 4 == 0){PRintf(" ");} temp = (a >> i) & 1; printf("%c",(temp == 1) ? '1' : '0'); }printf("/n");}int main(){int a;int b;printf("请输入一个32位的整数a:/n");scanf("%d",&a); b = fun(a);printf("The oringal is /n");rest(a);printf("The result is /n");rest(b);新闻热点
疑难解答