#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

int main() {
	// version using a vetor of bool (1 bit per element)
	vector<bool> v;  
	bool a=1;
	bool b=0;
	bool c=1;
	bool d=0;
	v.push_back(a); v.push_back(b); v.push_back(c); v.push_back(d); 
	// but using/converting vetor<bool> is not so easy
	for (int i=0; i<4; i++) 
		cout << v[i] <<" ";
	cout<<endl; 
	
	// version using a bitset 
	bitset<8> s; 
	s[3]=a;   // access elements as easily as in an array or a vector
	s[2]=b;
	s[1]=c; 
	s[0]=d;   // least significant bit (according to the standard)
	cout << s<<endl;    // streams the bitset as a string of '0' and '1' 
	cout << "0x"<< hex << s.to_ulong()<<endl; // convert the bitset to unsigned long
	cout << s[3] <<endl;     // access a specific bit
	cout << "Number of bits set: " << s.count()<<endl; 
	
	bitset<2400> ls;  
	ls[2201]=true; 
	return 0;
}