From d0550b5065e0c0f619f7c0c869d1fae9d7cdff53 Mon Sep 17 00:00:00 2001 From: heizaki-dawn <734653314@qq.com> Date: Wed, 6 Jan 2021 07:58:12 +0800 Subject: [PATCH] first commit --- .../Demo01+1.4.java" | 19 +++++++++ .../Demo02+1.4.java" | 24 +++++++++++ .../Demo03+1.4.java" | 26 ++++++++++++ .../Demo04+1.4.java" | 42 +++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 "java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo01+1.4.java" create mode 100644 "java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo02+1.4.java" create mode 100644 "java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo03+1.4.java" create mode 100644 "java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo04+1.4.java" diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo01+1.4.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo01+1.4.java" new file mode 100644 index 0000000..531432c --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo01+1.4.java" @@ -0,0 +1,19 @@ +package fang; + +import java.util.Scanner; + +public class Demo01 { + + public static void main(String[] args) { + Scanner scan=new Scanner(System.in); + System.out.println("请输入第一个数"); + int a =scan.nextInt(); + System.out.println("请输入第二个数"); + int b =scan.nextInt(); + System.out.println("请输入第三个数"); + int c =scan.nextInt(); + int sum=(a*a*a)+(b*b*b)+(c*c*c); + System.out.println(sum); + } + +} diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo02+1.4.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo02+1.4.java" new file mode 100644 index 0000000..ae0c9cf --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo02+1.4.java" @@ -0,0 +1,24 @@ +package fang; + +import java.util.Scanner; + +public class Demo02 { + + + public static void main(String[] args) { + Scanner scan =new Scanner(System.in); + System.out.println("请输入数值"); + int a =(int) scan.nextDouble(); + System.out.println("请输入幂值"); + int b=scan.nextInt(); + int c = 1; + for (int i = 1; i <= b; i++) { + c=a*c; + } + System.out.println(c); + } + + } + + + diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo03+1.4.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo03+1.4.java" new file mode 100644 index 0000000..e69171d --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo03+1.4.java" @@ -0,0 +1,26 @@ +package fang; + +import java.util.Random; +import java.util.Scanner; + +public class Demo03 { + + public static void main(String[] args) { + Scanner scan=new Scanner(System.in); + Random random =new Random(); + int[]a=new int[20]; + for (int i = 0; i < 20; i++) { + a[i]=random.nextInt(10)+1; + } + System.out.println("请输入数值"); + int b=scan.nextInt(); + int sum=0; + for (int i = 0; i < a.length; i++) { + if (b==a[i]) { + sum++; + } + } + System.out.println( sum); + } + +} diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo04+1.4.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo04+1.4.java" new file mode 100644 index 0000000..9a88bbc --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\237\246\345\244\251\347\277\224/Demo04+1.4.java" @@ -0,0 +1,42 @@ +package fang; + +import java.util.Random; + +public class Demo04 { + + public static void main(String[] args) { + Random random=new Random(); + int[]a=new int[10]; + for (int i = 0; i < a.length; i++) { + a[i]=random.nextInt(10)+1; + } + int max = a[0]; + int mix = a[0]; + int maxIndex=0; + int mixIndex=0; + + for (int i = 0; i < a.length; i++) { + if (maxa[i]) { + mix = a[i]; + mixIndex = i; + } + } + + int temp = a[0]; + a[0] = max; + a[maxIndex] = temp; + + temp = a[a.length-1]; + a[a.length-1] = mix; + a[mixIndex] = temp; + for (int i = 0; i < a.length; i++) { + System.out.println(a[i]); + } + } + + +} -- Gitee