diff --git "a/56 \350\265\265\346\225\217/20221215 Java \351\232\217\346\234\272\346\225\260.md" "b/56 \350\265\265\346\225\217/20221215 Java.\351\232\217\346\234\272\346\225\260.md" similarity index 100% rename from "56 \350\265\265\346\225\217/20221215 Java \351\232\217\346\234\272\346\225\260.md" rename to "56 \350\265\265\346\225\217/20221215 Java.\351\232\217\346\234\272\346\225\260.md" diff --git "a/56 \350\265\265\346\225\217/20221219 Java.\346\226\271\346\263\225.md" "b/56 \350\265\265\346\225\217/20221219 Java.\346\226\271\346\263\225.md" index 43e5c77e013b539f77c0e599d7a44bec5e979886..77e820ac2ef46901e9a27f19ba1da3d8bdca7652 100644 --- "a/56 \350\265\265\346\225\217/20221219 Java.\346\226\271\346\263\225.md" +++ "b/56 \350\265\265\346\225\217/20221219 Java.\346\226\271\346\263\225.md" @@ -1,6 +1,7 @@ 作业1 ``` + public class D6{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); @@ -38,4 +39,8 @@ public class D6 { } ``` +笔记 + +``` +``` diff --git "a/56 \350\265\265\346\225\217/20221220 Java.\346\226\271\346\263\225\345\206\205\345\256\271.md" "b/56 \350\265\265\346\225\217/20221220 Java.\346\226\271\346\263\225\345\206\205\345\256\271.md" new file mode 100644 index 0000000000000000000000000000000000000000..b322d693b39bb9d82c4004bbc622596cdc9f038b --- /dev/null +++ "b/56 \350\265\265\346\225\217/20221220 Java.\346\226\271\346\263\225\345\206\205\345\256\271.md" @@ -0,0 +1,94 @@ +1.编写函数,计算圆的面积和周长,在主函数中接受圆的半径,在自定义函数中计算并输出 + +import java.util.Scanner; +public class D4 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入圆的半径:"); + int bj = sc.nextInt(); + System.out.println("圆的周长是:"+zc(bj)); + System.out.println("圆的面积是:"+mj(bj)); + } + public static double zc(int bj){ + return 2*3.14*bj; + } + public static double mj(int bj){ + return 3.14*bj*bj; + } +} + +2.在主函数中产生20个0-10之间的随机数,将这20个随机数存入数组,并通过函数计算某个数在这些随机数中出现的次数(这“某个数”是在主函数中由用户输入的) + +import java.util.Arrays; +import java.util.Random; +import java.util.Scanner; +public class D5 { + public static void main(String[] args) { + int[] num = new int[20]; + for (int i=0; i<20; i++){ + Random sj=new Random(); + num[i]=sj.nextInt(10); + } + Scanner sc = new Scanner(System.in); + System.out.println("请输入某个数:"); + int x = sc.nextInt(); + sz(num,x); + } + public static void sz(int[]num,int x){ + int count=0; + for (int i=0; i