#12267: java AC


qaz5678 (nonono)

學校 : 不指定學校
編號 : 66803
來源 : [36.229.217.72]
最後登入時間 :
2017-07-30 22:37:05
a034. 二進位制轉換 | From: [61.228.29.243] | 發表日期 : 2017-06-22 12:45

import java.util.Scanner;

public class Test01 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

while (sc.hasNext()) {
int number = sc.nextInt();
StringBuilder binary = new StringBuilder();
int a, b;

do{
a = number / 2;
b = number % 2;
number = a;
binary.append(b);
}while(number > 0);
System.out.println(binary.reverse());
}
}
}

 
ZeroJudge Forum