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));
	}
}

 有什么不对可以提出来

相关文章:

  • 2021-12-16
  • 2021-03-30
  • 2021-08-31
  • 2021-07-09
  • 2021-11-17
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2021-12-04
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案