From 0fc26e6cb48437a995dde2711b89e90a451176dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BD=B3=E7=82=9C?= <626104790@qq.com> Date: Mon, 19 Dec 2022 13:32:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=ACnn=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221219 \344\275\263\347\202\234.md" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "26 \351\231\210\344\275\263\347\202\234/20221219 \344\275\263\347\202\234.md" diff --git "a/26 \351\231\210\344\275\263\347\202\234/20221219 \344\275\263\347\202\234.md" "b/26 \351\231\210\344\275\263\347\202\234/20221219 \344\275\263\347\202\234.md" new file mode 100644 index 0000000..ab9696c --- /dev/null +++ "b/26 \351\231\210\344\275\263\347\202\234/20221219 \344\275\263\347\202\234.md" @@ -0,0 +1,64 @@ +# 作业 + +```java +import java.util.Scanner; + +public class ok { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入两个数字"); + double no1 = sc.nextDouble(); + double no2 = sc.nextDouble(); + System.out.println(max(no1,no2)); + } + public static double max(double a, double b) { + return a>b?a:b; + } +} +``` + +```java +import java.util.Scanner; + +public class ok2 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入x,y,z"); + int x=sc.nextInt(); + int y=sc.nextInt(); + int z=sc.nextInt(); + System.out.println(sum(x,y,z)); + } + public static int sum(int x,int y,int z){ + return (x*x*x)+(y*y*y)+(z*z*z); + } + } +``` + +## 笔记 + +方法的调用格式是 方法名() + +例 getSum(a:100,b:200);参数调用 + +public static void getSum(int a,int b){ + + sout(a+b); + +} + +main(函数)主方法 + +定义方法的标准语法: + +public static 返回值类型 方法名(){ + + 方法体的具体代码 + +} + +返回值类型:基础类型和引用类型 void(无返回值) + +关于参数:在调用时叫:实际参数,定义时叫:形式参数 + +定义多个相同名的参数时,就调用输出多个。 \ No newline at end of file -- Gitee