#include <iostream>
#include <conio>
using namespace std;
void print (float*, int);
string binarry(int);
int main(int argc, char* argv[])
{ int x;
cout << "Konversi desimal ke binner \n";
cout << "Masukkan harga X : "; cin >> x;
string s = binary(X);
cout << "binary dari X : " << s << "\n";
getch();
return 0;
}
string binary(int n)
{ string s;
if (n%2 == 0) s ="0"; else s ="1";
if (n < 2) return s;
return binary(n/2)+s;
}
0 comments:
Posting Komentar