import java.util.Scanner;

public class Demo {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		System.out.println("请输入需要转换的数:");
		System.out.println("转换之后为:"+io(toBin(input.nextInt())));
	}
static String toBin(int hi) {
	if(hi/2 == 0) {return Integer.toString(hi%2);}
	return toBin(hi/2)+Integer.toString(hi%2);
}
static String io(String hi) {
	if(hi.indexOf("-") >=0) {
		hi = hi.replaceAll("-", "");
		return "-"+hi;
	}
	return hi;
}
}
最近下载更多
最代码官方  LV167 2021年6月20日
最近浏览更多
heqian  LV16 2023年1月10日
最代码官方  LV167 2021年6月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友