Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:35
Show Gist options
  • Save pinglunliao/c963530094a63ed2d223 to your computer and use it in GitHub Desktop.
Save pinglunliao/c963530094a63ed2d223 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
string msg;
while( n > 0)
{
if( n % 2 == 1 )
msg.insert(0, "1");
else
msg.insert(0, "0");
n = n / 2;
}
cout << msg << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment