#include <stdio.h> int main() { int num; scanf("%d",&num); int count=0; while(num!=0) { count++; num=num&(num-1);// } printf("count=%d\n",count); return 0; }
时间: 2024-10-13 11:19:09
#include <stdio.h> int main() { int num; scanf("%d",&num); int count=0; while(num!=0) { count++; num=num&(num-1);// } printf("count=%d\n",count); return 0; }