HDOJ 2051 Bitset
2016-03-31 10:20
351 查看
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
题意:把输入的十进制数转化为二进制数
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
题意:把输入的十进制数转化为二进制数
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); int[] a=new int[50]; int i=0; // if(n==0) // a[0]=0; while(n>0){ a[i++]=n%2; n=n/2; } for(int j=i-1;j>0;j--){ System.out.print(a[j]); } System.out.println(a[0]); } } }
相关文章推荐
- 淘宝大秒系统设计详解
- VC远程调试
- LeetCode 67 Add Binary
- 清除數據庫死鎖進程
- android studio 取消自动启动上次项目
- YJX_Driver_013_VM+WlnDbg安装
- 网页错误数字
- PullToRefreshListView 内嵌checkbox 数据丢失问题
- 欢迎使用CSDN-markdown编辑器
- C++多个文件共享同一头文件时全局变量的声明
- Android开发之如何监听让Service不被杀死
- c++封装链表实现-->学生信息管理分析系统
- 利用mail.jar发送邮件(简单版)
- Xcode磁盘空间大清理
- iOS开发-常用第三方开源框架介绍(你了解的ios只是冰山一角)
- Core Animation - 摇动+循环动态画圆
- Elasticsearch的三个重要的优化
- jQuery键盘控制方法,以及键值(keycode)对照表
- python if else单行
- 如何删除“无法删除文件,无法读取源文件或磁盘”文件