题目分析:
http://acm.hdu.edu.cn/showproblem.php?pid=2051
给出一个整数,转化为对应的二进制。
AC代码:
<span style="font-size:18px;">/**
*@xiaoran
*/
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<cstdlib>
#include<cctype>
#include<cmath>
#define LL long long
using namespace std;
int a[12];
void Bitset(int n){
int k=0;
while(n){
a[k++]=n%2;
n/=2;
}
for(int i=k-1;i>=0;i--){
cout<<a[i];
}
cout<<endl;
}
int main()
{
int n;
while(cin>>n){
Bitset(n);
}
return 0;
}
</span>