package my_mian_shi; import java.util.Random; class IntToStringBit { /** * 递归方式求整数的二进制 * @param a * @return */ public static String intToBit(int a) { if(a==0) return "0"; if(a==1) return "1"; return intToBit(a/2)+(a%2)+""; } public static void main(String[] args) { int a=new Random().nextInt(1000); System.out.println(a); System.out.println(IntToStringBit.intToBit(a)); } }
有什么不对可以提出来