Problem Description
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
123
Sample Output
11011
题意:输入十进制,输出它的二进制
0<n<=1000
/*
题意:十进制转换二进制
除2取余数+倒序输出
*/
code:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int dp[65];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(dp,0,sizeof(dp));
int k=0;
while(n)
{
dp[k++]=n%2;
n=n/2;
}
for(int i=k-1;i>=0;--i)
cout<<dp[i];
cout<<endl;
}
return 0;
}