Problem Description
Give you a numberon base ten,you should output it on base two.(0 < n < 1000)
Input
For each casethere is a postive number n on base ten, end of file.
Output
For each caseoutput a number on base two.
Sample Input
1
2
3
Sample Output
1
10
11
题意:
十进制转二进制。
#include <cstdio>
#include<cstring>
using namespace std;
int main()
{
int n,a[1000];
while(cin>>n)
{
int i=0;
while(n!=0)
{
a[i]=n%2;
n=n/2;
i++;
}
for(int j=i-1;j>=0;j--)
{
printf("%d",a[j]);
}printf("\n");
}
}