As many suggested already, I would have done this like this:
myBitset
will keep the flags. 1
(set) for print flag and 0
(clear) for non-print flag
#include <bitset>
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char** argv){
std::vector<int> a {1,2,3,4,5,6,7,8,9,10};
std::bitset<10> myBitset;
myBitset.set(3); // set fourth bit ==> display 4
myBitset.set(6); // set seventh bit ==> display 7
myBitset[8] = true; // set nineth bit ==> display 9
myBitset[9] = myBitset[3]; // set 10th bit ==> display 10
std::cout << "Mybitset" << myBitset << endl;
for (int i=0; i<a.size(); i++)
{
if (myBitset.test(i))
{
std::cout << a.at(i);
}
}
return (0);
}
The ouput would be:
1101001000
47910
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…