From 0b72411ca2015248017536c65d111c3714e841c2 Mon Sep 17 00:00:00 2001 From: fdzcxy212206298 Date: Thu, 10 Oct 2024 16:02:50 +0800 Subject: [PATCH 1/4] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..93490c0 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# pan + -- 2.34.1 From 8d8303e4b8a29f9f42fc65fa4a2c89c61eeaff2c Mon Sep 17 00:00:00 2001 From: psj Date: Thu, 10 Oct 2024 17:12:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E9=A2=98=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 3 ++ .idea/misc.xml | 6 +++ .idea/modules.xml | 9 ++++ .idea/vcs.xml | 6 +++ jinzhi/jinzhi.iml | 11 +++++ jinzhi/src/JinZhi.java | 103 +++++++++++++++++++++++++++++++++++++++++ test6298.iml | 11 +++++ 7 files changed, 149 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 jinzhi/jinzhi.iml create mode 100644 jinzhi/src/JinZhi.java create mode 100644 test6298.iml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8c68c6b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/jinzhi/jinzhi.iml b/jinzhi/jinzhi.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/jinzhi/jinzhi.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/jinzhi/src/JinZhi.java b/jinzhi/src/JinZhi.java new file mode 100644 index 0000000..6b26597 --- /dev/null +++ b/jinzhi/src/JinZhi.java @@ -0,0 +1,103 @@ +import java.util.Scanner; + +public class JinZhi { + + // 辅助方法:将任意进制的数转换为十进制 + /** + * 将任意进制的数转换为十进制数 + * + * @param number 要转换的数的字符串表示 + * @param base 该数的原始进制 + * @return 转换后的十进制数 + */ + public static int toDecimal(String number, int base) { + int decimalValue = 0; // 十进制结果 + int power = 0; // 当前位的权重(幂次) + + // 从字符串的最后一个字符开始遍历 + for (int i = number.length() - 1; i >= 0; i--) { + char digit = number.charAt(i); // 当前字符 + int value = 0; // 当前字符对应的十进制值 + + // 根据字符计算其十进制值 + if (Character.isDigit(digit)) { + value = digit - '0'; // 如果是数字,直接减去'0'的ASCII码 + } else if (digit >= 'A' && digit <= 'F') { + value = digit - 'A' + 10; // 如果是大写字母,减去'A'的ASCII码后加10 + } else if (digit >= 'a' && digit <= 'f') { + value = digit - 'a' + 10; // 如果是小写字母,减去'a'的ASCII码后加10 + } else { + throw new IllegalArgumentException("输入的数字中包含无效字符: " + digit); + } + + // 将当前字符的十进制值乘以权重后累加到结果中 + decimalValue += value * Math.pow(base, power); + power++; // 权重增加 + } + + return decimalValue; + } + + // 辅助方法:将十进制数转换为任意进制 + /** + * 将十进制数转换为任意进制的数 + * + * @param decimalValue 要转换的十进制数 + * @param base 目标进制 + * @return 转换后的目标进制数的字符串表示 + */ + public static String fromDecimal(int decimalValue, int base) { + if (decimalValue == 0) { + return "0"; // 如果十进制数为0,直接返回"0" + } + + StringBuilder result = new StringBuilder(); // 用于存储转换结果的StringBuilder对象 + char[] digits = "0123456789ABCDEF".toCharArray(); // 表示所有可能的进制字符的数组 + + // 使用循环进行进制转换 + while (decimalValue > 0) { + int remainder = decimalValue % base; // 取余数作为当前位的值 + result.insert(0, digits[remainder]); // 将当前位的值添加到结果的开头 + decimalValue /= base; // 十进制数除以目标进制,为下一次循环做准备 + } + + return result.toString(); // 返回转换后的结果字符串 + } + + // 主方法:执行进制转换 + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); // 创建Scanner对象用于读取用户输入 + + // 读取要转换的数、其原始进制和目标进制 + System.out.print("请输入要转换的数: "); + String number = scanner.nextLine(); + System.out.print("请输入该数的原始进制(2-16): "); + int inputBase = scanner.nextInt(); + + // 读取目标进制 + System.out.print("请输入目标进制(2-16): "); + int targetBase = scanner.nextInt(); + + // 验证输入的有效性 + if (inputBase < 2 || inputBase > 16 || targetBase < 2 || targetBase > 16) { + System.out.println("无效的进制。进制必须在2到16之间。"); + return; // 如果输入无效,则直接返回,不执行后续操作 + } + + try { + // 将输入的数转换为十进制数 + int decimalValue = toDecimal(number, inputBase); + + // 将十进制数转换为目标进制数 + String result = fromDecimal(decimalValue, targetBase); + + // 输出转换后的结果 + System.out.println(number + "初始是" + inputBase + "进制;" + "在" + targetBase + "进制下是"+ result); + } catch (IllegalArgumentException e) { + // 捕获并处理非法参数异常 + System.out.println("错误: " + e.getMessage()); + } + + scanner.close(); // 关闭Scanner对象,释放资源 + } +} diff --git a/test6298.iml b/test6298.iml new file mode 100644 index 0000000..8b2ade9 --- /dev/null +++ b/test6298.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file -- 2.34.1 From 13cd438b287cbfb102af869a03fd243afbb221c4 Mon Sep 17 00:00:00 2001 From: psj Date: Thu, 10 Oct 2024 18:34:32 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E9=A2=98=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- out/production/jinzhi/JinZhi.class | Bin 0 -> 2836 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 out/production/jinzhi/JinZhi.class diff --git a/out/production/jinzhi/JinZhi.class b/out/production/jinzhi/JinZhi.class new file mode 100644 index 0000000000000000000000000000000000000000..c328a5f488939d42436612d6fe8e37f7ffa9cb14 GIT binary patch literal 2836 zcmaJ@Yj;z}72RW9>B{mo2pIvAAJ~LY*)j10M-V&E`T>c+CMhOPjnjr}=^|f{C07p~ z>5HVMHYFjX2{qVxKoa7vRZ>G%m+aOgeDB{VGUii0wqFvuM^}m5nr3OOxo2k1W1l@| z&gdWC{QXM+ZMfk=00S<(grCS^(1jxyQt`5ipSs|{fD=EH-&f>tR1Ufeb_}}^M#Krj ziDS|%DtAUyn58(56E1iVlhUXYaTgL8lPf=WA}PNqC(=%2El%= ze&NI~o%odu^J}U98x?0&ye8my#*CZkJp#5s{eXbdoro9$YkSSOaWFGFY$Ols!!fRS zdJ|ziHlQa>IWH_K=@By};OyOR#*d7c9Rj84M2`_RNA;M%hCuIe{iNO$)8o;m{&doe zM>|6GApv{DjGAcy(M|cJ9?Q_b;JPr0C!UWg1FkYAykR{>Wi4XG7_e;ZV~JBnQlPv) zt%pza>0)VTUAE5cbv;TcKFYi0ZMztUhxP| z0%|I($Kw)eh2<@iHe*fw)}lNBGd`9{cjakvrRmAYPgERWA*pzsRVd)d`>hI9CxiU|#qI4`iJcpm=`yuikyl6B$*)&#aKfB8=C+>QIw z<4c!swS`mew6@PX%}Gdb+c#yJzn{4e#Jx4VUppfpz)#D>+dyrQr&$N>9@oX7HYXe|c`+ zg0uYTYs+8UTzc~(3s-xsiuW~qfVVV!h>HRZMa{Vz1WvWw#Se3{7nbkNx;Sf{?wYAywwuC z_qPiVrvA!Z4c8^4X0&M74c^w$+~oU2v2StvE=jtYY-Gg2u%N_%@amPi?>`!4N@Y=Vg~nn4PN-a)vF*0)X~?2P zi3Am|GJ^{ZUL^}#&~6Jly!HhsS5fY@yPG3H$1Gl?)Oj5n`Pug|+;SFiyN=4Oc20C_ z>zK8rf4jAL5%$4FI0omTdYoC5dhJ=bvM8H}cDHK6>zJsVsGe9r`HAqw-QzYft~{K5 zc(Upy;o0&jb-_(}4HH~T4m?3EJQ`|v7Sv4f9u6;AR0!&4+ow!a`HMG}IY*u}4up5_{>i1zK2O1M9T4oWsg z12H(hfhL6b8g)YW{gwYFlv3FtibW@NA)6rl}&! z<<25JgP)^f9_xEQhu5EETje%u?D6k3h;iF(=5m-%*A)_EQM;eD0qjK?p5tkTczpX&ivy(RAgO$wgdgIp zpTEQW4Ppo{v$kHLk1)L)#WaR74+D!hmZ$y@FVzs~mepdXW(#TF#rm2?H6w)b#c+o) z4lrsNZlf1{#I%WTgsiy|#+_nhSzkMFp7CWx%1Wz(@{mS$6)&jxv5G^2_ulz0@E=is LO+G7m`Ct4G=p)WR literal 0 HcmV?d00001 -- 2.34.1 From 32f65c8bdd6db4efa5b9d015492d3942234f8b97 Mon Sep 17 00:00:00 2001 From: cwx <1635985168@qq.com> Date: Thu, 10 Oct 2024 19:07:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 3 + .idea/misc.xml | 6 + .idea/modules.xml | 9 ++ .idea/pan.iml | 9 ++ .idea/vcs.xml | 6 + chen123/chen123.iml | 11 ++ chen123/src/Main.java | 5 + chen123/src/jisuan.java | 211 ++++++++++++++++++++++++++++ out/production/chen123/JS.class | Bin 0 -> 4356 bytes out/production/chen123/Main.class | Bin 0 -> 516 bytes out/production/chen123/jisuan.class | Bin 0 -> 409 bytes 11 files changed, 260 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/pan.iml create mode 100644 .idea/vcs.xml create mode 100644 chen123/chen123.iml create mode 100644 chen123/src/Main.java create mode 100644 chen123/src/jisuan.java create mode 100644 out/production/chen123/JS.class create mode 100644 out/production/chen123/Main.class create mode 100644 out/production/chen123/jisuan.class diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e1f830b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5aebfd1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/pan.iml b/.idea/pan.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/pan.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/chen123/chen123.iml b/chen123/chen123.iml new file mode 100644 index 0000000..37cc804 --- /dev/null +++ b/chen123/chen123.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/chen123/src/Main.java b/chen123/src/Main.java new file mode 100644 index 0000000..3e59c38 --- /dev/null +++ b/chen123/src/Main.java @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file diff --git a/chen123/src/jisuan.java b/chen123/src/jisuan.java new file mode 100644 index 0000000..1107087 --- /dev/null +++ b/chen123/src/jisuan.java @@ -0,0 +1,211 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class jisuan{ + public static void main(String[] args) { + JS win=new JS(); + } +} +class JS extends JFrame implements ActionListener{ + private StringBuilder sBuilder = new StringBuilder(); + JTextArea text=new JTextArea(); + double a,b; + Double sum; + int i; + public JS() + { + setBounds(100,100,400,400); + setTitle("计算器"); + this.setLayout(new BorderLayout()); + JPanel p1=new JPanel(); + JPanel p2=new JPanel(); + text.setPreferredSize(new Dimension (370,60)); + p2.setLayout(new FlowLayout()); + p1.add(text); + this.add(p1,BorderLayout.NORTH); + + + p2.setLayout(new GridLayout(5,4)); + JButton button[]=new JButton[20]; + button[0]=new JButton("C"); + button[1]=new JButton(" "); + button[2]=new JButton("%"); + button[3]=new JButton("÷"); + button[4]=new JButton("7"); + button[5]=new JButton("8"); + button[6]=new JButton("9"); + button[7]=new JButton("x"); + button[8]=new JButton("4"); + button[9]=new JButton("5"); + button[10]=new JButton("6"); + button[11]=new JButton("—"); + button[12]=new JButton("1"); + button[13]=new JButton("2"); + button[14]=new JButton("3"); + button[15]=new JButton("+"); + button[16]=new JButton(""); + button[17]=new JButton("0"); + button[18]=new JButton("."); + button[19]=new JButton("="); + + for(int i=0;i