fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4. uint64_t matrix = 0b0110101001101011011110100110101011101010011010100110111001101010ULL;
  5.  
  6. int column = 3; // "d"-column
  7.  
  8. int result = 0;
  9. int source_bitpos = 7 - column; // "point" to last entry in this column
  10. for (int target_bitpos = 0; target_bitpos < 8; ++target_bitpos)
  11. {
  12. bool bit = (matrix >> source_bitpos) & 1; // "extract" bit
  13. result |= bit << target_bitpos; // add bit if it was set
  14. source_bitpos += 8; // move one up in table
  15. }
  16.  
  17. std::cout << result << std::endl;
  18. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
32