+ 1
Another way to make the same function?
2 Antworten
0
Integer. toBinaryString() you can use
Please refer the syntax through internet I can be incorrect here
0
import java.util.Scanner;
//tu código va aquí
public class Converter{
public static String toBinary(int num){
/*String binary="";
while(num>0){
binary = (num%2) + binary;
num /=2;
}*/
return Integer.toBinaryString(num);
}
}
public class Program {
public static void main(String[ ] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
System.out.print(Converter.toBinary(x));
}
}
//It works