C++ 清除一点
示例
C风格的位操作
可以使用按位AND运算符(&)清除一位。
//x位将被清除 number &= ~(1LL << x);
使用std::bitset
reset(x)或set(x,false)-清除位置上的位x。
std::bitset<5> num(std::string("01100")); num.reset(2); //num现在是01000 num.reset(0); //num仍然是01000 num.set(3,false); //num现在是00000
可以使用按位AND运算符(&)清除一位。
//x位将被清除 number &= ~(1LL << x);
reset(x)或set(x,false)-清除位置上的位x。
std::bitset<5> num(std::string("01100")); num.reset(2); //num现在是01000 num.reset(0); //num仍然是01000 num.set(3,false); //num现在是00000