Bit Array in C++

前端 未结 8 1207
旧时难觅i
旧时难觅i 2021-02-05 06:09

When working with Project Euler problems I often need large (> 10**7) bit array\'s.

My normal approach is one of:

bool* sieve = new bool[N];

bool sieve[         


        
8条回答
  •  忘掉有多难
    2021-02-05 06:54

    You can use a byte array and index into that. Index n would be in byte index n/8, bit # n%8. (In case std::bitset is not available for some reason).

提交回复
热议问题