fork download
  1. unsigned reverse(unsigned int h)
  2. {
  3. bitset<32> hash;
  4. // 1. hash = hash + (hash << 16);
  5. for(int i = 0; i < 32; i += 16)
  6. h = h - ((h & (((1LL << 16) - 1) << i)) << 16);
  7. // 2. hash = hash ^ (hash >> 11);
  8. hash = h;
  9. for(int i = 20; i >= 0; i--)
  10. hash[i] = hash[i] ^ hash[i + 11];
  11. h = hash.to_ulong();
  12. // 3. hash = hash + (hash << 3);
  13. for(int i = 0; i < 32; i += 3)
  14. h = h - ((h & (((1LL << 3) - 1) << i)) << 3);
  15. // 4. hash = hash ^ (hash >> 6);
  16. hash = h;
  17. for(int i = 25; i >= 0; i--)
  18. hash[i] = hash[i] ^ hash[i + 6];
  19. h = hash.to_ulong();
  20. // 5. hash = hash + (hash << 10);
  21. for(int i = 0; i < 32; i += 10)
  22. h = h - ((h & (((1LL << 10) - 1) << i)) << 10);
  23. return h;
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'unsigned int reverse(unsigned int)':
prog.cpp:3:2: error: 'bitset' was not declared in this scope
  bitset<32> hash;
  ^
prog.cpp:3:13: error: 'hash' was not declared in this scope
  bitset<32> hash;
             ^
stdout
Standard output is empty