判断是否为2的倍数

    xiaoxiao2025-04-20  5

     用二进制实现,偶然接触,还不错诶

    bool isPowerOfTwo(int n) { return (n > 0) && (!(n & (n - 1))); }

     

    最新回复(0)