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.Scanner;
/**
* 位集合
* 題目的意思也就是将一個十進制的數轉換為二進制然後輸出
* @author 逸川同學
*
*/
public class P2051 {
private static Scanner scanner;
public static void main(String[] args) {
scanner = new Scanner(System.in);
while(scanner.hasNext()){
int n = scanner.nextInt();
String string = "";
while(n>0){
string = n%2+string;
n = n/2;
}
System.out.println(string);
}
}
}