第一次提交

master
lincong 10 months ago
commit b949e38672

@ -0,0 +1,5 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

@ -0,0 +1,27 @@
import java.util.Scanner;
public class Transform4381 {
//此代码不实现界面
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入输入数字: ");
String input = scanner.nextLine();
System.out.print("请输入从进制 (2, 8, 10, 16): ");
int fromBase = scanner.nextInt();
System.out.print("请输入到进制 (2, 8, 10, 16): ");
int toBase = scanner.nextInt();
try {
int number = Integer.parseInt(input, fromBase);
String result = Integer.toString(number, toBase);
System.out.println("转换结果: " + result);
} catch (NumberFormatException e) {
System.out.println("输入的数字在指定的进制中无效。");
}
}
}
Loading…
Cancel
Save