zoukankan      html  css  js  c++  java
  • Bitset

    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
    1
    2
    3
     
    Sample Output
    1
    10
    11
     
     1 #include <stdio.h> 
     2  
     3 int main(){
     4     int number;
     5     char result[20];
     6     int length;
     7     int i;
     8     
     9     while((scanf("%d",&number))!=EOF){
    10         i=0;
    11         while(number){
    12             result[i]=number%2+'0';
    13             i++;
    14             number/=2;
    15         }
    16         length=i;
    17         
    18         for(i=length-1;i>=0;i--)
    19             printf("%c",result[i]);
    20             
    21         printf("
    ");
    22     }
    23         
    24     return 0;
    25 }
  • 相关阅读:
    函数、对象
    webpack配置
    创智培训内容
    oracle方法
    Weblogic
    药店
    ip
    jdk账号
    ansible
    目录编码
  • 原文地址:https://www.cnblogs.com/zqxLonely/p/4058173.html
Copyright © 2011-2022 走看看