1 #include<stdio.h> 2 int ans; 3 int cus(int x) 4 { 5 if(x) 6 { 7 if(x&1) 8 ++ans; 9 cus(x>>1); 10 } 11 else 12 return ans; 13 } 14 int main() 15 { 16 int n,x; 17 scanf("%d",&n); 18 while(n--) 19 { 20 ans=0; 21 scanf("%d",&x); 22 printf("%d\n",cus(x)); 23 } 24 }
时间: 2024-10-18 11:34:29