#include<stdio.h> #include<string.h> int main( void ) { char* s="1101"; char* p=s+strlen(s); unsigned i=0; unsigned num=0; while (p-->s) num^=!(*p^'1')<<i++; printf("%u\n",num); return 0; }
[此贴子已经被作者于2017-11-19 17:27编辑过]
#include<stdio.h> int main( void ) { char* s="1101"; char* p=s; unsigned num=0; while (*p) { num<<=1; num^=!(*p++^'1'); } printf("%u\n",num); return 0; }
[此贴子已经被作者于2017-11-20 07:58编辑过]