Give you a number on base ten,you should output it on base two.(0 < n < 1000)
Input
For each case there is a postive number n on base ten, end of file.
Output
For each case output a number on base two.
Sample Input
1 2 3Sample Output
11011
十进制转二进制,第一次遇到超级水题
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,i,num;
while(cin>>n)
{
num=0;
int a[15];
while(n)
{
a[num++]=n%2;
n/=2;
}
for(i=num-1;i>=0;i--)
{
cout<<a[i];
}
cout<<endl;
}
}