hdu 2051 Bitset

http://acm.hdu.edu.cn/showproblem.php?pid=2051

这题就是简单的求二进制的值,我本来打算找一个%。。的可是没有找,只有8进制%o,十六进制%x;

所以只有写代码:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <math.h>

int main()

{

    int n,k,r,a[50];

    while(scanf("%d",&n)!=EOF)

    {

          k=0;

          while(n)

          {

              r=n%2;

              a[k++]=r;

              n=n/2;    

          }

          for(int i=k-1;i>=0;--i)

          printf("%d",a[i]);

          printf("\n");

    }

    //system("pause");

    return 0;

}

原文地址:https://www.cnblogs.com/yuelingzhi/p/2131304.html