fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <algorithm>
  4. #include <bitset>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main(int argc, char * argv[])
  10. {
  11. string s;
  12. cin >> s;
  13. if (s.size() != 8)
  14. {
  15. cerr << "Wrong length\n";
  16. return 1;
  17. }
  18. unsigned long long x = *reinterpret_cast<const unsigned long long*>(s.c_str());
  19.  
  20. // Если в обратном порядке:
  21.  
  22. reverse(s.begin(),s.end());
  23. unsigned long long y = *reinterpret_cast<const unsigned long long*>(s.c_str());
  24.  
  25. // Шестнадцатеричная
  26.  
  27. cout << hex << x << " " << y << endl;
  28.  
  29. // Десятичная:
  30.  
  31. cout << dec << x << " " << y << endl;
  32.  
  33. // Двоичная:
  34.  
  35. cout << bitset<64>(x) << " " << bitset<64>(y) << endl;
  36.  
  37. }
  38.  
Success #stdin #stdout 0s 5304KB
stdin
abcdefgh
stdout
6867666564636261  6162636465666768
7523094288207667809   7017280452245743464
0110100001100111011001100110010101100100011000110110001001100001   0110000101100010011000110110010001100101011001100110011101101000