fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main()
  5. {
  6. int decimal = 1234;
  7. std::vector<int> binary;
  8.  
  9. int i = 0;
  10. int value = decimal;
  11. while( value > 0 )
  12. {
  13. binary.push_back(value & 1);
  14. value >>= 1;
  15. ++i;
  16. }
  17.  
  18.  
  19. for( std::vector<int>::reverse_iterator it = binary.rbegin(); it != binary.rend(); ++it )
  20. std::cout << *it;
  21.  
  22. return (0);
  23. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
10011010010