Tanky WooRSS

HDOJ 2051 Bitset

29 Jul 2010
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2051

 // Author: Tanky Woo
// HDOJ 2051

#include 
#include 
using namespace std;

int n;
int arr[30];
int main()
{
    while(scanf("%d", &n;) != EOF)
    {
        memset(arr, 0, sizeof(arr));
        int cnt = 0;
        while(n)
        {
            arr[cnt] = n%2;
            n /= 2;
            cnt++;
        }
        for(int i=cnt-1; i>=0; --i)
            printf("%d", arr[i]);
        printf("\n");
    }
    return 0;
}