Guest User

C++

a guest
Aug 16th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8. int n;
  9.  
  10. cout << "Inserisci un numero: ";
  11. cin >> n;
  12. int log2n = (int) log2(n);
  13. int powz = 1 << log2n;
  14.  
  15. do {
  16. cout << ((n&powz) >> log2n--);
  17. } while(powz>>=1);
  18.  
  19. return 0;
  20. }
Add Comment
Please, Sign In to add comment