public class BinaryRepresentation
{
public static int recur_depth = 0 ;
public static void main(String[] args) {
int n = Integer.parseInt(args[0]);
String output = ConvertToBinary(n);
System.out.printf("Result: %d -> %s\n", n, output);
}
public static String ConvertToBinary(int n){
if (n==0)
return "0";
else if (n==1)
return "1";
else {
return ConvertToBinary(n/2) + n%2;
}
}
}
这不就是10进制转换为2进制么
你现在输出是什么样子呢?
return之前先print一下呗