From 9ed1f1fce669533d8417bf91f30e89eb1d99e521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8E=E5=87=BD?= <3084917167@qq.com> Date: Sat, 17 Dec 2022 20:55:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B9=9D=E4=B8=8B=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 --- ...35\346\254\241\344\275\234\344\270\232.md" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "02 \351\231\210\346\230\216\345\207\275/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232.md" diff --git "a/02 \351\231\210\346\230\216\345\207\275/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232.md" "b/02 \351\231\210\346\230\216\345\207\275/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232.md" new file mode 100644 index 0000000..de3ef20 --- /dev/null +++ "b/02 \351\231\210\346\230\216\345\207\275/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232.md" @@ -0,0 +1,57 @@ +# 第九次作业 + + + +定义一函数,用于求2个数中的较大数,并将其返回,这两个数在主函数中由用户输入。 + +```java +package Nahida; + +import com.sun.xml.internal.fastinfoset.tools.XML_SAX_StAX_FI; + +import java.util.Scanner; + +public class K1 { + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + System.out.println("请输入num1的值"); + double num1=sc.nextInt(); + System.out.println("请输入num2的值"); + double num2=sc.nextInt(); + double max=getsum(num1,num2); + System.out.println(max); + + + } + public static double getsum(double num1,double num2){ + double max=(num1>num2)?num1:num2; + return max; + + + } + +} + +``` + +在主函数中下x,y,z,编写函数计算这三个数的立方并返回计算结果。 + + ```java + public class MEI { + public static void main(String[] args) { + int result=count(1,2,3); + System.out.println("X,Y,Z立方和为"+result); + } + public static int count(int x,int y,int z){ + int cube1=x*x*x; + int cube2=y*y*y; + int cube3=z*z*z; + System.out.println("X立方为"+cube1); + System.out.println("Y立方为"+cube2); + System.out.println("Z立方为"+cube3); + int result=cube1+cube2+cube3; + return result; + } + } + ``` + -- Gitee