Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int main() {
- int n;
- cout << "Inserisci un numero: ";
- cin >> n;
- int log2n = (int) log2(n);
- int powz = 1 << log2n;
- do {
- cout << ((n&powz) >> log2n--);
- } while(powz>>=1);
- return 0;
- }
Add Comment
Please, Sign In to add comment