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
 
 
很简单  十进制化为二进制
题目中未提到小数 但应该考虑到
#include<iostream>
using namespace std;
void f(double n)
{
int i,j,k,a[],p=;
double t;
k=n;
t=n-k;
if(k==)cout<<;
while(k){
if(k%==)a[p++]=;
else a[p++]=;
k=k/;
}
for(i=p-;i>=;i--)cout<<a[i];
if(t){
cout<<".";
while(){
t*=;
if(t>=){
cout<<;
if(t==)break;
else t-=;
}
else cout<<;
}
}
cout<<endl;
}
int main()
{
double n;
while(cin>>n){
f(n);
}
//system("pause");
return ;
}

W - Bitset(第二季水)的更多相关文章

  1. F - The Fun Number System(第二季水)

    Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...

  2. D - Counterfeit Dollar(第二季水)

    Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...

  3. N - Robot Motion(第二季水)

    Description A robot has been programmed to follow the instructions in its path. Instructions for the ...

  4. S - 骨牌铺方格(第二季水)

    Description          在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.         例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...

  5. R - 一只小蜜蜂...(第二季水)

    Description          有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数.         其中,蜂房的结构如下所示.     ...

  6. I - Long Distance Racing(第二季水)

    Description Bessie is training for her next race by running on a path that includes hills so that sh ...

  7. Y - Design T-Shirt(第二季水)

    Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...

  8. B - Maya Calendar(第二季水)

    Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old ...

  9. T - 阿牛的EOF牛肉串(第二季水)

    Description          今年的ACM暑期集训队一共有18人,分为6支队伍.其中有一个叫做EOF的队伍,由04级的阿牛.XC以及05级的COY组成.在共同的集训生活中,大家建立了深厚的 ...

随机推荐

  1. Java访问kafka的时候java.nio.channels.ClosedChannelException解决办法

    import java.util.Properties; import kafka.javaapi.producer.Producer; import kafka.producer.KeyedMess ...

  2. Android生命周期注意事项

                                    生命周期图解     以下英文引用全部来自google官方文档说明,方便理解. onCreate (Bundle savedInstan ...

  3. linux上备份Oracle时EXP-00091的错误解决方法

    unix/linux上备份Oracle时EXP-00091的错误解决方法 unix/linux上备份数据时的错误解决方法 EXP-00091: Exporting questionable stati ...

  4. myeclipse8.6 for spring环境配置

     

  5. JS截取字符串:slice(),substring()和substr()

    var string='abcdefg' 1.slice() string.slice(startLocation [, endLocation]) ps1:2个参数可以为负数,若参数值为负数,则将该 ...

  6. java一点东西(3)

    运算符的优先级:()优先级最高 ! ++ -- 单目运算符 * / % + - > < <= >= == != && || 赋值符号 面向对象设计步骤:1.发现 ...

  7. hdu 1587

    Problem Description As you know, Gardon trid hard for his love-letter, and now he's spending too muc ...

  8. Qss样式(二)

    Qss 其实就是一段文本,当然得按一定格式来写.下面请看Qss的语法格式: 选择器 { 属性1:值:属性2:值:--属性n:值:} 对应上篇文章的Qss样式: 现在我们可以来解释这段话的意思了: 对应 ...

  9. mysql install

    ./scripts/mysql_install_db --user=mahao01 --basedir=/home/mahao01/local/mysql --datadir=/home/mahao0 ...

  10. 第二章IPC——IPC与开启多进程

    问题 一.IPC ①.什么是IPC  ②.为什么要有IPC 二.多进程 ①.如何开启多进程  ②.系统如何创建多进程 三.多进程引发的问题 问:私有进程(利用":+进程名")能否共 ...