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合并list

    import java.util.ArrayList; import java.util.List;   import com.google.common.collect.Lists;   priva ...

  2. Cocoapods依赖管理

    对于iOS App的开发,几乎都采用了Cocoapods来管理第三方库,那么对于开发人员来说,这是必备技能,必须要掌握如何使用.这篇文章就是介绍如何安装和使用CocoaPods的. 简单来说,就是专门 ...

  3. Linux中Firefox——Firebug插件安装及使用

    Firebug的安装方法即打开方式同httpfox Firebug使用指南: Firebug可以随时编辑页面:在HTML标签中,点击窗口上方的"inspect"命令,然后再选择页面 ...

  4. (原)lua提示cannot load incompatible bytecode

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5754872.html 前段时间用终端和zerobrane运行torch的lua程序.zerobrane ...

  5. PHP APC缓存配置、使用详解

    一.APC缓存简介 APC,全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”.它为我们提供了缓存和优化PHP的中间代码的框架. APC的缓存分两部分:系统缓存和用户数据缓 ...

  6. python3.4+selenium爬58同城(一)

    爬取http://bj.58.com/pbdn/0/pn2/中除转转.推广商品以外的产品信息,因为转转和推广的详情信息不规范,需要另外写一个方法存放,后期补上,详情页如下 这周学习了爬虫,但是遇到一些 ...

  7. C语言运算符学习笔记

    运算符不仅具有不同的优先级,还有不同的结合性.在表达式中,各运算量参与运算的先后顺序不仅要遵守运算符优先级别的规定,还要受运算符结合性的制约,以便确定是自左向右进行运算还是自右向左进行运算. C语言的 ...

  8. hdu just a hook(线段树,区间修改)

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  9. oc语言--内存管理

    一.基本原理 1.什么是内存管理 1> 移动设备的内存及其有限,每个app所能占用的内存是有限制的 2> 当app所占用的内存较多时,系统就会发出内存警告,这是需要回收一些不需要的内存空间 ...

  10. Logging in Java

    Common logging: Log4j1仅仅作为一个实际的日志框架,commons-logging作为门面,统一各种日志框架的混乱格局 基本的commons logging Dependency: ...