fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int main()
  5. {
  6. int number{10};
  7. // std::cin>>number;
  8.  
  9. int tempNumber = number;
  10.  
  11. while (tempNumber)
  12. {
  13. const int tempNumberLength = floor(log2(tempNumber)) + 1;
  14. const int binaryChar = tempNumber >> tempNumberLength;
  15. std::cout << binaryChar;
  16.  
  17. tempNumber/=2;
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5252KB
stdin
Standard input is empty
stdout
0000