From 2ba36dc70e317c4c05420306e72f3a50da67003e Mon Sep 17 00:00:00 2001 From: xiao-a-qi <1307421235@qq.com> Date: Tue, 5 Jan 2021 21:13:46 +0800 Subject: [PATCH] first commit --- .../Less14.java" | 25 ++++++++ .../less12.java" | 57 +++++++++++++++++++ .../less13.java" | 36 ++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 "java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/Less14.java" create mode 100644 "java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less12.java" create mode 100644 "java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less13.java" diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/Less14.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/Less14.java" new file mode 100644 index 0000000..3f9bd35 --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/Less14.java" @@ -0,0 +1,25 @@ +import java.util.Scanner; + +public class Less14 { + + + + public static void main(String[] args) { + // TODO Auto-generated method stub + Scanner scan =new Scanner(System.in); + System.out.println("请输入n的值"); + int n=scan.nextInt(); + System.out.println("请输入m的值"); + int m=scan.nextInt(); + System.out.println("最终结果为"+num(n,m)); + } + public static int num(int n,int m) { + int sum=1; + for (int i = 1; i <=n; i++) { + sum=sum*m; + } + return sum; + } + + +} diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less12.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less12.java" new file mode 100644 index 0000000..d52eb36 --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less12.java" @@ -0,0 +1,57 @@ +import java.util.Random; +import java.util.Scanner; + +public class less12 { + + public static void main(String[] args) { + Scanner scan =new Scanner(System.in); + Random ran=new Random(); + int a[] =new int [10]; + for (int i = 0; i <10; i++) { + //a[i]=scan.nextInt(); + a[i]=ran.nextInt(100)+1; + } + System.out.println("数据已填充"); + int max=a[0]; + int min=a[0]; + for (int i = 0; i < a.length; i++) { + if (maxa[i]) { + min=a[i]; + } + } + System.out.println("change之前"); + for (int i = 0; i < a.length; i++) { + System.out.println(a[i]+"\t"); + } + + change(max,min,a); + System.out.println(); + System.out.println("change之后"); + for (int i = 0; i < a.length; i++) { + System.out.println(a[i]+"\t"); + }} + private static void change(int max, int min, int[] a) { + // TODO Auto-generated method stub + int maxinde=0; + int mininde=0; + int temp; + for (int i = 0; i < a.length; i++) { + if (max==a[i]) { + maxinde=i; + } + if (min==a[i]) { + mininde=i; + } + } + temp=a[0]; + a[0]=max; + a[maxinde]=temp; + temp=a[a.length-1]; + a[a.length-1]=min; + a[mininde]=temp; + + }} + diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less13.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less13.java" new file mode 100644 index 0000000..5904520 --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\270\251\345\271\277\347\224\237/less13.java" @@ -0,0 +1,36 @@ +import java.util.Random; +import java.util.Scanner; + +public class less13 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + Scanner scan =new Scanner(System.in); + Random ra =new Random(); + int a[]=new int [20]; + for (int i = 0; i <20; i++) { + a[i]=ra.nextInt(10)+1; + } + System.out.println("请输入一个值"); + int b=scan.nextInt(); + System.out.println(b+"出现了"+num(b,a)+"次"); + } + + private static int num(int d, int[] a) { + // TODO Auto-generated method stub + int c; + int sum=0; + for (int i = 0; i <20; i++) { + c=a[i]; + System.out.println(c+"\t"); + if (c==d) { + sum++; + } + } + System.out.println(); + return sum; + } + + + +} -- Gitee