diff --git "a/05\350\260\242\351\223\226\346\265\251/1126 \350\260\242\351\223\226\346\265\251.md" "b/05 \350\260\242\351\223\226\346\265\251/1126 \350\260\242\351\223\226\346\265\251.md" similarity index 100% rename from "05\350\260\242\351\223\226\346\265\251/1126 \350\260\242\351\223\226\346\265\251.md" rename to "05 \350\260\242\351\223\226\346\265\251/1126 \350\260\242\351\223\226\346\265\251.md" diff --git "a/05\350\260\242\351\223\226\346\265\251/20221129 \350\260\242\351\223\226\346\265\251.md" "b/05 \350\260\242\351\223\226\346\265\251/20221129 \350\260\242\351\223\226\346\265\251.md" similarity index 100% rename from "05\350\260\242\351\223\226\346\265\251/20221129 \350\260\242\351\223\226\346\265\251.md" rename to "05 \350\260\242\351\223\226\346\265\251/20221129 \350\260\242\351\223\226\346\265\251.md" diff --git "a/05 \350\260\242\351\223\226\346\265\251/20221202 if\345\222\214switch.md" "b/05 \350\260\242\351\223\226\346\265\251/20221202 if\345\222\214switch.md" new file mode 100644 index 0000000000000000000000000000000000000000..f08f6aecd0d1b490447d5776229656b02eb2c2db --- /dev/null +++ "b/05 \350\260\242\351\223\226\346\265\251/20221202 if\345\222\214switch.md" @@ -0,0 +1,121 @@ +```java +import java.util.Scanner; + +public class dd1 { + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + System.out.println("请输入车型"); + String cx= sc.next(); + Scanner km=new Scanner(System.in); + System.out.println("请输入公里"); + int gl= km.nextInt(); + if (gl>3) { + switch (cx) { + case "夏利": + System.out.println((gl - 3) * 2.1 + 3); + break; + case "富康": + System.out.println((gl - 3) * 2.4 + 3); + break; + case "桑塔纳": + System.out.println((gl - 3) * 2.7 + 3); + break; + } + } + else { + switch (cx){ + case"夏利": + System.out.println("3元"); + break; + case"富康": + System.out.println("4元"); + break; + case"桑塔纳": + System.out.println("5元"); + break; + } + } + } +} +``` + +```java +import java.util.Scanner; + +public class DD2 { + public static void main(String[] args) { + Scanner a=new Scanner(System.in); + System.out.println("请输入年"); + int nian=a.nextInt(); + Scanner b=new Scanner(System.in); + System.out.println("请输入月"); + int yue=b.nextInt(); + Scanner c=new Scanner(System.in); + System.out.println("请输入日"); + int ri=a.nextInt(); + int ey; + if(nian % 4==0 &&nian %100!=0||nian%400==0){ + ey=29; + }else ey=28; + + switch (yue){ + case 1: + System.out.println(ri); + break; + case 2: + System.out.println(ri+31); + break; + case 3: + System.out.println(ri+ey+31); + break; + case 4: + System.out.println(ri+ey+31*2); + break; + case 5: + System.out.println(ri+ey+31*2+30); + break; + case 6: + System.out.println(ri+ey+31*3+30); + break; + case 7: + System.out.println(ri+ey+31*3+30*2); + break; + case 8: + System.out.println(ri+ey+31*4+30*2); + break; + case 9: + System.out.println(ri+ey+31*5+30*2); + break; + case 10: + System.out.println(ri+ey+31*5+30*3); + break; + case 11: + System.out.println(ri+ey+31*6+30*3); + break; + case 12: + System.out.println(ri+ey+31*6+30*4); + break; + } + } + +} +``` + +三元运算符 + +~~~java +int a = 10; +int b = 20; +int c = a > b ? a : b; // 判断 a>b 是否为真,如果为真取a的值,如果为假,取b的值 +先执行关系表达式 看结果 是不是执行 如果执行 就执行关系表达式1 否则执行表达式2 +~~~ + +if语句 + +~~~java +格式1: +if (关系表达式) { + 语句体; +} +首先计算关系表达式的值 如果关系表达式的值为true就执行语句体 如果关系表达式的值为false就不执行语句体 继续执行后面的语句内容 +~~~ \ No newline at end of file diff --git "a/05 \350\260\242\351\223\226\346\265\251/20221208 \345\276\252\347\216\257\346\225\260\347\273\204.md" "b/05 \350\260\242\351\223\226\346\265\251/20221208 \345\276\252\347\216\257\346\225\260\347\273\204.md" new file mode 100644 index 0000000000000000000000000000000000000000..e27c17296598f11ffa2e3eac27d04d1e84b5f14f --- /dev/null +++ "b/05 \350\260\242\351\223\226\346\265\251/20221208 \345\276\252\347\216\257\346\225\260\347\273\204.md" @@ -0,0 +1,22 @@ +```java +import java.util.Scanner; + +public class D15 { + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + + + int[]scores=new int[5]; + + for( int i=0;i<5;i++){ + System.out.println("输入一个数值"); + scores[i]= sc.nextInt(); + } + + + for(int b=0;b<5;b++){ + System.out.println(" "+scores[b]); + } + } +} +``` \ No newline at end of file diff --git "a/05 \350\260\242\351\223\226\346\265\251/20221219\345\207\275\346\225\260.md" "b/05 \350\260\242\351\223\226\346\265\251/20221219\345\207\275\346\225\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..c9bd97b66cec33a0cfb37c280082511a86cc6bc1 --- /dev/null +++ "b/05 \350\260\242\351\223\226\346\265\251/20221219\345\207\275\346\225\260.md" @@ -0,0 +1,49 @@ +~~~java +import java.util.Scanner; + +public class D777 { + public static void main(String[] args) { + Scanner d1 =new Scanner(System.in); + System.out.println("请输入数据"); + int a1= d1.nextInt(); + System.out.println("请输入数据"); + int a2= d1.nextInt(); + int max=max(a1,a2); + System.out.println("最大值为"+max); + } + public static int max(int a1, int a2) { + if(a1>a2) + return a1; + else + return a2; + + } + +} +~~~ + +~~~jav +import java.util.Scanner; + +public class D777 { + public static void main(String[] args) { + Scanner d1 =new Scanner(System.in); + System.out.println("请输入数据"); + int x= d1.nextInt(); + System.out.println("请输入数据"); + int y= d1.nextInt(); + System.out.println("请输入数据"); + int z= d1.nextInt(); + int sum=sum(x,y,z); + System.out.println("三个数的立方是"+ sum); + } + public static int sum(int x, int y,int z) { + int sum=x*x*x+y*y*y+z*z*z; + return sum; + + + } + +} +~~~ + diff --git "a/05\350\260\242\351\223\226\346\265\251/2022121\350\260\242\351\223\226\346\265\251.md" "b/05 \350\260\242\351\223\226\346\265\251/2022121\350\260\242\351\223\226\346\265\251.md" similarity index 100% rename from "05\350\260\242\351\223\226\346\265\251/2022121\350\260\242\351\223\226\346\265\251.md" rename to "05 \350\260\242\351\223\226\346\265\251/2022121\350\260\242\351\223\226\346\265\251.md" diff --git "a/05 \350\260\242\351\223\226\346\265\251/2022124 if\345\222\214\345\276\252\347\216\257.md" "b/05 \350\260\242\351\223\226\346\265\251/2022124 if\345\222\214\345\276\252\347\216\257.md" new file mode 100644 index 0000000000000000000000000000000000000000..92abb242cbec38d22c3eb63705fb640e5c2567a6 --- /dev/null +++ "b/05 \350\260\242\351\223\226\346\265\251/2022124 if\345\222\214\345\276\252\347\216\257.md" @@ -0,0 +1,63 @@ +```java +import java.util.Scanner; + +public class D10 { + public static void main(String[] args) { + //2.用户分别输入数 a,数b,让程序实现从a 开始循环到b. + // 输出"有生之年,能看到中国队出线吗?" + int a,b,i; + Scanner sc=new Scanner(System.in); + System.out.println("输出a的数"); + a= sc.nextInt(); + System.out.println("输出b的数"); + b= sc.nextInt(); + if (a>b){ + for (i=0;inum){ + System.out.println("你猜的数字太大了"); + } else if (shuru=2&&count<=6) { + System.out.println("你一点点聪明"); + }else{ + System.out.println("你真蠢"); + } + } +} +``` + +# 笔记: \ No newline at end of file