1 #include <iostream> 2 using namespace std; 3 int GetCount(int num) 4 { 5 int m=0; 6 while(num) 7 { 8 num &=(num-1); 9 m++; 10 } 11 return m; 12 } 13 int main() 14 { 15 int a; 16 cin>>a; 17 cout<<GetCount(a)<<endl; 18 }
原文地址:https://www.cnblogs.com/zaijiefangbeidawang/p/8196745.html
时间: 2024-10-12 19:34:00