From 7d16d94923784e9b170b80c7efb3579ee9980abf Mon Sep 17 00:00:00 2001 From: csxy <3208295266@qq.com> Date: Tue, 18 Mar 2025 14:49:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 38 +++++++++++ .idea/.gitignore | 8 +++ .idea/dictionaries/.xml | 3 + .idea/encodings.xml | 8 +++ .idea/inspectionProfiles/Project_Default.xml | 8 +++ .idea/misc.xml | 14 ++++ pom.xml | 17 +++++ src/main/java/com/heima/springboot/Code2.java | 36 ++++++++++ src/main/java/com/heima/springboot/Main.java | 29 ++++++++ src/main/java/com/heima/springboot/Table.java | 24 +++++++ src/main/java/com/heima/springboot/Test.java | 26 +++++++ .../java/com/heima/springboot/likou1.java | 67 +++++++++++++++++++ 12 files changed, 278 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/dictionaries/.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 pom.xml create mode 100644 src/main/java/com/heima/springboot/Code2.java create mode 100644 src/main/java/com/heima/springboot/Main.java create mode 100644 src/main/java/com/heima/springboot/Table.java create mode 100644 src/main/java/com/heima/springboot/Test.java create mode 100644 src/main/java/com/heima/springboot/likou1.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/dictionaries/.xml b/.idea/dictionaries/.xml new file mode 100644 index 0000000..cee4164 --- /dev/null +++ b/.idea/dictionaries/.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..63574ec --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..e2fe4b9 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..82dbec8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f2f5840 --- /dev/null +++ b/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + com.heima.springboot + lanqiaobei + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/src/main/java/com/heima/springboot/Code2.java b/src/main/java/com/heima/springboot/Code2.java new file mode 100644 index 0000000..9d587c9 --- /dev/null +++ b/src/main/java/com/heima/springboot/Code2.java @@ -0,0 +1,36 @@ +package com.heima.springboot; + +import java.util.Scanner; + +/** + * @version 1.0 + * @author: HZY + * @date: 2025/3/13 21:23 + * @Content: 串的比较 + * C1 = aababdbdaabc + * C2 = aabc + */ +public class Code2 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String s = null; + s = sc.next(); + String c = null; + c = sc.next(); + char[] c1 = c.toCharArray(); + char[] s1 = s.toCharArray(); + int []next = new int[c.length()]; + next[0] = 0; + next[1] = 1; + + + for (int i = 0; i < s.length(); i++) { + if(i==0) { + continue; + } + char []codeQ = new char[i-1]; + char []codeH = new char[i-1]; + + } + } +} diff --git a/src/main/java/com/heima/springboot/Main.java b/src/main/java/com/heima/springboot/Main.java new file mode 100644 index 0000000..b62cc97 --- /dev/null +++ b/src/main/java/com/heima/springboot/Main.java @@ -0,0 +1,29 @@ +package com.heima.springboot; + +/** + * @version 1.0 + * @author: HZY + * @date: 2025/3/12 19:36 + * @Content: 修正汉诺塔递归逻辑 + */ +public class Main { + public static void main(String[] args) { + Hanoi hanoi = new Hanoi(); + int n = 3; // 盘子数 + hanoi.move(n, 'A', 'C', 'B'); + } +} + +class Hanoi { + public void move(int n, char A, char C, char B) { + if (n == 1) { + System.out.println(A + " -> " + C); + return; + } + //借和栈 + //借用B, + move(n - 1, A, B, C); //把A上面的除了最后一个的所有挪到B + System.out.println(A + " -> " + C); //A的最后一个去C + move(n - 1, B, C, A); //把从A那拿的都给C + } +} diff --git a/src/main/java/com/heima/springboot/Table.java b/src/main/java/com/heima/springboot/Table.java new file mode 100644 index 0000000..7822b31 --- /dev/null +++ b/src/main/java/com/heima/springboot/Table.java @@ -0,0 +1,24 @@ +package com.heima.springboot; + +/** + * @version 1.0 + * @author: HZY + * @date: 2025/3/12 19:36 + * @Content: + */ + +public class Table { + private int data; + + public Table(int data) { + this.data = data; + } + + public int getData() { + return data; + } + + public void setData(int data) { + this.data = data; + } +} diff --git a/src/main/java/com/heima/springboot/Test.java b/src/main/java/com/heima/springboot/Test.java new file mode 100644 index 0000000..d9e1fc1 --- /dev/null +++ b/src/main/java/com/heima/springboot/Test.java @@ -0,0 +1,26 @@ +package com.heima.springboot; + +import java.math.BigInteger; +import java.sql.SQLOutput; + +/** + * @version 1.0 + * @author: HZY + * @date: 2025/3/17 17:18 + * @Content: + */ +public class Test { + public static void main(String[] args) { + long a = 4; + long b = 1; + BigInteger c = BigInteger.ZERO; + long l = System.currentTimeMillis(); + for (long i = 1; i <= a; i++) { + b *= i; + c = c.add(new BigInteger("" + b)); + } + System.out.println(b); + System.out.println(c); + System.out.println(System.currentTimeMillis() - l); + } +} diff --git a/src/main/java/com/heima/springboot/likou1.java b/src/main/java/com/heima/springboot/likou1.java new file mode 100644 index 0000000..62ff8ec --- /dev/null +++ b/src/main/java/com/heima/springboot/likou1.java @@ -0,0 +1,67 @@ +package com.heima.springboot; + +import java.util.Scanner; + +/** + * @version 1.0 + * @author: HZY + * @date: 2025/3/17 21:22 + * @Content: 力扣习题 + * 给你一个字符串 s ,下标从 0 开始 ,且长度为偶数 n 。字符串 恰好 由 n / 2 个开括号 '[' 和 n / 2 个闭括号 ']' 组成。 + *

+ * 只有能满足下述所有条件的字符串才能称为 平衡字符串 : + *

+ * 字符串是一个空字符串,或者 + * 字符串可以记作 AB ,其中 A 和 B 都是 平衡字符串 ,或者 + * 字符串可以写成 [C] ,其中 C 是一个 平衡字符串 。 + * 你可以交换 任意 两个下标所对应的括号 任意 次数。 + *

+ * 返回使 s 变成 平衡字符串 所需要的 最小 交换次数。 + *

+ *

+ *

+ * 示例 1: + *

+ * 输入:s = "][][" + * 输出:1 + * 解释:交换下标 0 和下标 3 对应的括号,可以使字符串变成平衡字符串。 + * 最终字符串变成 "[[]]" 。 + * 示例 2: + *

+ * 输入:s = "]]][[[" + * 输出:2 + * 解释:执行下述操作可以使字符串变成平衡字符串: + * - 交换下标 0 和下标 4 对应的括号,s = "[]][][" 。 + * - 交换下标 1 和下标 5 对应的括号,s = "[[][]]" 。 + * 最终字符串变成 "[[][]]" 。 + * 示例 3: + *

+ * 输入:s = "[]" + * 输出:0 + * 解释:这个字符串已经是平衡字符串。 + */ +public class likou1 { + public static void main(String[] args) { + //1为【,-1为】 + int judging = 0; + /* + a为【 + */ + int a = 0; + /* + b为】 + */ + int b = 0; + String s = new Scanner(System.in).next(); + char[] sCharArray = s.toCharArray(); + for (int i = 0; i < sCharArray.length; i++) { + if (sCharArray[i] == ']') { + for (int j = sCharArray.length; j > 0; j--){ + if(sCharArray[j-1] == '['){ + judging++; + } + } + } + } + } +}