10進数から2進数に変換 (std::bitset)

int n = 100

// 8ビット長のビット集合を生成
bitset<8> b(n);

// 01100100
cout << b << endl;

C++ ビット集合(std::bitset)

あるものは使おう。