您的位置:首页 > 理论基础 > 计算机网络

HDU2051Bitset

2017-12-06 00:49 127 查看
本文章仅用于笔记。部分知识点来源于网络,授权请联系作者(947043511@qq.com)。

题目

Give you a number on base ten,you should output it on base two.(0 < n < 1000)

InputFor each case there is a postive number n on base ten, end of file.
OutputFor each case output a number on base two.
Sample Input
1
2
3


Sample Output
1
10
11


解题

import java.util.Scanner;

public class HDU2051
{
//Bitset
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
while(s.hasNextInt())
{
int n=s.nextInt();
String m="";
while(n>0)
{
m=n%2+m;
n=n/2;
}
System.out.println(m);
}
}
}

求来波关注! 谢谢啦0.0!

小小小作者 

@Fanny0602
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息