Compare commits
No commits in common. 'master' and 'main' have entirely different histories.
@ -0,0 +1,8 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/cxk/cxk.iml" filepath="$PROJECT_DIR$/cxk/cxk.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/git.iml" filepath="$PROJECT_DIR$/.idea/git.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,36 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class wlh {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.println("请输入原始进制 (2-16): ");
|
||||||
|
int fromBase = scanner.nextInt();
|
||||||
|
|
||||||
|
System.out.println("请输入目标进制 (2-16): ");
|
||||||
|
int toBase = scanner.nextInt();
|
||||||
|
|
||||||
|
System.out.println("请输入要转换的数字: ");
|
||||||
|
String number = scanner.next();
|
||||||
|
|
||||||
|
// 将原始进制数转换为十进制数
|
||||||
|
long decimalNumber = convertToDecimal(number, fromBase);
|
||||||
|
|
||||||
|
// 将十进制数转换为目标进制数
|
||||||
|
String result = convertFromDecimal(decimalNumber, toBase);
|
||||||
|
|
||||||
|
System.out.println("转换结果: " + result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将任意进制数转换为十进制数
|
||||||
|
private static long convertToDecimal(String number, int base) {
|
||||||
|
return Long.parseLong(number, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将十进制数转换为任意进制数
|
||||||
|
private static String convertFromDecimal(long decimal, int base) {
|
||||||
|
return Long.toString(decimal, base).toUpperCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue