
24.10.2008, 22:04
|
|
Участник форума
Регистрация: 07.07.2008
Сообщений: 161
Провел на форуме: 1027635
Репутация:
234
|
|
Держи!
Код:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string get_binary(int a)
{
string res = "";
while(a)
{
res += a%2+'0';
a /= 2;
}
reverse(res.begin(), res.end());
return res;
}
int main()
{
int a;
cin >> a;
cout << get_binary(a) << endl;
return 0;
}
|
|
|