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. OpenCV——写手势识别碰到的各种错误

    最近写opencv的手势识别时,真的碰到了好多好多程序运行时的错误. 比如: 位置冲突: findcontours函数的使用错误: 各种符号的加载错误: 这种符号加载的错误,一般用网上各种方法就可以解 ...

  2. [Leetcode] Two Sum (C++)

    我在Github上新建了一个解答Leetcode问题的Project, 大家可以参考, 目前是Java 为主,里面有leetcode上的题目,解答,还有一些基本的单元测试,方便大家起步. 题目: Gi ...

  3. Linux下安装MySQL步骤

    1.下载安装包(这里是32位的): MySQL-client-5.6.13-1.rhel5.i386.rpm MySQL-server-5.6.13-1.rhel5.i386.rpm 2.安装 rpm ...

  4. ni

    坚强歌词 马天宇 - 坚强 天使的翅膀挥动着的光芒一路走来学会了坚强每一次你努力认真的模样让我很欣赏 雨天的路上会有一缕阳光温暖被淋湿的希望再小的河也能汇成海洋让我去远航 一路上陪伴我的目光是最感动的 ...

  5. JS设置获取cookies

    结合JavaScript权威指南,加上项目开发时在网上搜集的资料,整理了两种设置和获取cookie的方法. <script> //设置cookie  方法一function setCook ...

  6. keil禁止给uncalled segment分配空间

    把target options中的device页中选上"Use LX51 ...",然后在LX51 Misc页中的Misc Control中填入"REMOVEUNUSED ...

  7. Material风格的Quick组件,妈妈再也不用担心我的界面不好看了

    https://github.com/papyros/qml-material http://www.zhihu.com/question/38523930

  8. Qt之Windows资源文件(.rc文件)

    简述 在Windows下使用Qt时,通常会用到Windows的资源文件 - 为exe设置信息,其中包括:文件说明.产品名称.产品版本.版权等信息... 由于是Windows平台相关的东西,Qt助手中对 ...

  9. HDOJ-1010 Tempter of the Bone(dfs+剪枝)

    http://acm.hdu.edu.cn/showproblem.php?pid=1010 给出一个n*m的迷宫 X为墙 .为空地 S为起点 D为终点 给出时间T 每走一步花费一单位的时间 走过的空 ...

  10. POJ1988 并查集的使用

    Cube Stacking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 21157   Accepted: 7395 Ca ...