hdu 2051 Bitset 把一个十进制转化为2进制数

来源:互联网 发布:网络兼职做什么赚钱 编辑:程序博客网 时间:2024/05/19 15:22

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

itoa函数可以吧十进制传话为2或8或16进制等

////  main.cpp//  160929////  Created by 刘哲 on 17/4/13.//  Copyright © 2016年 my_code. All rights reserved.////#include <bits/stdc++.h>#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <map>#include <set>#include <queue>#include <deque>#include <list>#include <bitset>#include <stack>#include <stdlib.h>#define lowbit(x) (x&-x)using namespace std;int main(){    int n;    while(cin>>n){        char s[10];        itoa(n,s,2);        cout<<s<<endl;    }    return 0;}

0 0