int LowBit(int n)
{
return (n & -n);
}
int GetBit(int n)
{
int ans = 0;
for (int num = n; num > 0; num -= LowBit(num)){
cout << LowBit(num) << endl;
ans++;
}
return ans;
}
文章目录位运算基础知识与或非异或进阶应用lowbit状态压缩位运算基础知识与或非异或进阶应用lowbit 返回二进制数的最低位1的值。int LowBit(int n){ return (n & -n);}int GetBit(int n){ int ans = 0; for (int num = n; num > 0; num -= LowBit(num)){ cout << LowBit(num) <&