国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Java > 正文

HDU 2051 JAVA

2019-11-06 07:21:23
字體:
來源:轉載
供稿:網友

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

import java.util.*;class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int N=sc.nextInt(); int R=2; if(N<0){N=-N;System.out.print("-");} int x=N/R;int y=N%R; char chs[]={'0','1'}; int []a=new int [50];int i=0; a[0]=N%R; while(x!=0){ i++; y=x%R; a[i]=y; x=x/R; } int b[]=new int[i+1]; for(int k=0;k<i+1;k++){ // System.out.print(a[k]+" a"); b[k]=a[i-k]; //System.out.print(b[k]+" "); } for(int j=0;j<b.length;j++){ System.out.print(chs[b[j]]); } System.out.println(); } }}
上一篇:HDU 2052 JAVA

下一篇:java面試題

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 广元市| 兰溪市| 新巴尔虎左旗| 牡丹江市| 张北县| 宁陵县| 八宿县| 同仁县| 图片| 绥滨县| 微山县| 津市市| 改则县| 贵港市| 上杭县| 汾西县| 张家口市| 岳阳县| 左权县| 荣成市| 财经| 平顶山市| 加查县| 南岸区| 沁水县| 安顺市| 乌鲁木齐市| 苍南县| 北海市| 库伦旗| 西安市| 达州市| 邵阳市| 霞浦县| 治多县| 宣化县| 中西区| 镇康县| 商洛市| 甘谷县| 申扎县|