From f93d4162d148b4978ca5c7139e3a41436fa545c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=B5=E5=BF=B5?= <2324752546@qq.com> Date: Wed, 14 Dec 2022 20:43:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AC=AC=E4=B8=83=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022 1214\344\275\234\344\270\232.md" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "47 \346\235\216\345\277\265\345\277\265/2022 1214\344\275\234\344\270\232.md" diff --git "a/47 \346\235\216\345\277\265\345\277\265/2022 1214\344\275\234\344\270\232.md" "b/47 \346\235\216\345\277\265\345\277\265/2022 1214\344\275\234\344\270\232.md" new file mode 100644 index 0000000..3ba2a8a --- /dev/null +++ "b/47 \346\235\216\345\277\265\345\277\265/2022 1214\344\275\234\344\270\232.md" @@ -0,0 +1,38 @@ +# 作业: + +## 一: + +购买档位 + +~~~ Java +public class zuoye1 { + public static void main(String[] args) { + + for (int i = 1; i < 100; i++) { + if (i * 4.05 + (100 - i) * 5.06 == 445.4) { + System.out.println("第二档" + i + "立方,第三档是" + (100 - i) + "立方"); + } + } + + } +} +~~~ + +## 二: + +九九乘法表 + +~~~ Java +public class zuoye2 { + + public static void main(String[] args) { + for (int a = 9; a >= 1; a--) { + for (int b = 9; b >= a; b--) { + System.out.print(b + "*" + a + "=" + a * b + "\t"); + } + System.out.println(); + } + } +} +~~~ + -- Gitee From a202ffd19b6b3b543a15be815973e8f4230fb405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=B5=E5=BF=B5?= <2324752546@qq.com> Date: Fri, 16 Dec 2022 09:26:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?12=E6=9C=8816=E5=8F=B7=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022 1215 \346\226\271\346\263\225.md" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 "47 \346\235\216\345\277\265\345\277\265/2022 1215 \346\226\271\346\263\225.md" diff --git "a/47 \346\235\216\345\277\265\345\277\265/2022 1215 \346\226\271\346\263\225.md" "b/47 \346\235\216\345\277\265\345\277\265/2022 1215 \346\226\271\346\263\225.md" new file mode 100644 index 0000000..9578823 --- /dev/null +++ "b/47 \346\235\216\345\277\265\345\277\265/2022 1215 \346\226\271\346\263\225.md" @@ -0,0 +1,48 @@ +# 作业: + +### 1:定义一函数,用于求2个数中的较大数,并将其返回,这2个数字在主函数中由用户输入 + +~~~ Java +import java.util.Scanner; + +public class zuoye3 { + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + System.out.println("请输入第一个数:"); + int number1 = s.nextInt(); + System.out.println("请输入第二个数:"); + int number2 = s.nextInt(); + System.out.println("较大的数为:"+max(number1,number2)); + } + public static int max(int number1,int number2) { + return number1>number2?number1:number2; + } +} +~~~ + +### 2:在主函数中从键盘接收X, Y , Z3个数,编写函数计算这3个数的立方和并返回计算结果:S=X3+Y3+Z3 + +~~~ Java +import java.util.Scanner; + +public class zuoye4 { + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + System.out.println("请输入第一个数:"); + int x = s.nextInt(); + System.out.println("请输入第二个数:"); + int y = s.nextInt(); + System.out.println("请输入第三个数:"); + int z = s.nextInt(); + System.out.println(h(x,y,z)+"="+sum(x)+"+"+sum(y)+"+"+sum(z)); + } + public static int sum(int a) { + return a*a*a; + } + + public static int h(int a , int b, int c) { + return a*a*a+b*b*b+c*c*c; + } +} +~~~ + -- Gitee