WA (line:2)答案不正確您的答案為: The parity of is 2 (mod 2). 正確答案為: The parity of 10 is 1 (mod 2).
#include<stdio.h> #include<math.h> char out[100]={}; int main() { int len=0,num=0,a=0,in=0,i=0; while(scanf("%d",&in)!=EOF) { if(in!=0) { a=in; len=(int)floor(log2(a))+1; for(i=0;i<len;i++) { out[len-1-i]=(a&1)+48; a=(a>>1); } out[i]='\0'; printf("The parity of %s is %d (mod 2).\n",out,in); } else { return 0; } } return 0; }