diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/B.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/B.java" new file mode 100644 index 0000000000000000000000000000000000000000..06b843871b63be8ca4cd07802837ec6753c7f785 --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/B.java" @@ -0,0 +1,21 @@ +import java.util.Scanner; + +public class B { + + public static void main(String[] args) { + // TODO Auto-generated method stub +// 定义一个函数,用于计算m的n次幂, +// m和n在主函数中由用户输入,调用自定义函数进行计算,并输出结果 + Scanner scan=new Scanner(System.in); + System.out.println("请输入底数"); + int m=scan.nextInt(); + System.out.println("请输入 次幂"); + double n=scan.nextDouble(); + double sum=1; + for (int i = 1; i <= n; i++) { + sum=sum*m; + } + System.out.println("结果为:"+sum); + } + +} diff --git "a/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/C.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/C.java" new file mode 100644 index 0000000000000000000000000000000000000000..21b372a16faac5feb7dd284516eb3e55ded632e9 --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/C.java" @@ -0,0 +1,27 @@ +import java.util.Random; +import java.util.Scanner; + +public class C { + + public static void main(String[] args) { + // TODO Auto-generated method stub +// 在主函数中产生20个0-10之间的随机数,将这20个随机数存入数组, +// 并通过函数计算某个数在这些随机数中出现的次数(这“某个数”是在主函数中由用户输入的) + Scanner scan=new Scanner(System.in); + Random ran=new Random(); + int[] a=new int[20]; + for (int i = 0; i < 20; i++) { + a[i]=ran.nextInt(10)+1; + } + System.out.println("请输入一个数"); + int b=scan.nextInt(); + int sum=0; + for (int i = 0; i < 20; 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\202\271\346\265\267\345\205\265/G.java" "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/G.java" new file mode 100644 index 0000000000000000000000000000000000000000..2f5ebac46273942d8bb276c9757bd6acb03ffc2a --- /dev/null +++ "b/java\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\351\202\271\346\265\267\345\205\265/G.java" @@ -0,0 +1,53 @@ +import java.util.Scanner; + +public class G { + + public static void main(String[] args) { + // TODO Auto-generated method stub +// 在主函数中接收10个数存入数组,在自定义函数中,将该数组中的最大值与第一个元素交换, +// 最小值与最后一个元素交换,然后在主函数中输出交换后的数组 + Scanner scan=new Scanner(System.in); + int[] a=new int[5]; + for (int i = 0; i <5; i++) { + System.out.println("请输入一个数"); + int num=scan.nextInt(); + } + int max=a[0]; + int min=a[0]; + for (int i = 0; i < a.length; i++) { + if(min>a[i]) { + min=a[i]; + } + if(max