#include <iostream>
using namespace std;
int funcao(int n, int pot, int bin) {
bin += (n % 2)* pot;
n = n/2;
pot = pot *10;
if (n <= 0) {
return bin;
}
bin = funcao(n, pot, bin);
}
int main() {
int n,pot,bin;
cout << endl << " Digite o Numero: ";
cin >> n;
pot = 1;
bin = 0;
bin = funcao(n, pot, bin);
//while (n > 0){
// bin += (n % 2)* pot;
// pot *= 10;
// n = n/2;
//}
cout << " " << "Result: " << bin;
cin.get();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGZ1bmNhbyhpbnQgbiwgaW50IHBvdCwgaW50IGJpbikgewoJCgliaW4gKz0gKG4gJSAyKSogcG90OwoJbiA9IG4vMjsKCXBvdCA9IHBvdCAqMTA7CgkKCWlmIChuIDw9IDApIHsKCQlyZXR1cm4gYmluOwoJfQoJYmluID0gZnVuY2FvKG4sIHBvdCwgYmluKTsKfQoKaW50IG1haW4oKSB7CglpbnQgbixwb3QsYmluOwoKICAgIGNvdXQgPDwgZW5kbCA8PCAiICBEaWdpdGUgbyBOdW1lcm86ICI7CiAgICBjaW4gPj4gbjsKICAgIHBvdCA9IDE7CiAgICBiaW4gPSAwOwogICAgYmluID0gZnVuY2FvKG4sIHBvdCwgYmluKTsKICAgIC8vd2hpbGUgKG4gPiAwKXsKICAgIC8vICAgIGJpbiArPSAobiAlIDIpKiBwb3Q7CiAgICAvLyAgICBwb3QgKj0gMTA7CiAgICAvLyAgICBuID0gbi8yOwogICAgLy99CiAgICBjb3V0IDw8ICIgICIgPDwgIlJlc3VsdDogIiA8PCBiaW47CiAgICBjaW4uZ2V0KCk7CglyZXR1cm4gMDsKfQ==