fork(1) download
  1. #include <cstdio>
  2.  
  3. #if defined(_MSC_VER) || defined(__BORLANDC__)
  4. #define Q64 "%I64d\n"
  5. #define OCT(i) i##I64
  6. typedef __int64 oct64;
  7. #else
  8. #define Q64 "%lld\n"
  9. #define OCT(i) i##LL
  10. typedef long long oct64;
  11. #endif
  12.  
  13. //16 -> 8
  14. oct64 hex_to_oct(unsigned int h){
  15. oct64 o = OCT(0), d = OCT(1);
  16. for(; h != 0; h >>= 3){
  17. o += (oct64)(h & 0x7) * d;
  18. d *= OCT(10);
  19. }
  20. return o;
  21. }
  22.  
  23.  
  24. int main(void){
  25. //проверка
  26. printf(Q64, hex_to_oct(0x1234));
  27. printf(Q64, hex_to_oct(0xABCDEF));
  28. printf(Q64, hex_to_oct(0xFFFFFFFF));
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
11064
52746757
37777777777