diff --git "a/09\346\233\271\346\255\243\346\263\242/11\346\234\210\347\254\224\350\256\260\346\200\273\347\273\223.md" "b/09\346\233\271\346\255\243\346\263\242/11\346\234\210\347\254\224\350\256\260\346\200\273\347\273\223.md" new file mode 100644 index 0000000000000000000000000000000000000000..e039029cfaa9e205ca5d787b303bbb161d46f646 --- /dev/null +++ "b/09\346\233\271\346\255\243\346\263\242/11\346\234\210\347\254\224\350\256\260\346\200\273\347\273\223.md" @@ -0,0 +1,71 @@ +## 数值 + +整数:byte, short, int(默认), long + +小数:float(单精), double(双精(默认)) + +字符:charset (char,Asc转数字) + +## 非数值 + +布尔:true, false + +字符串:string + + + +byte——short,char——int——long——float——double + +byte short char类型的数据,在运算时,会自动提升为int. + +## 扫描器 + +1.创建扫描器 Scanner sc=new Scanner(System.in); + +2.提示用户输入 (sout) + +3.创建变量接收用户的输入 例:int name=sc.nextInt() + +4.处理和使用变量(sout) + + + +## 运算符 + +自增和自减 ++ —— 例:int a=10 a+=a++ a=11 + +++ ——所在的表达式里,出现了其他的运算符时候,谁在前面就先用谁。 + +例如; int c3=10; 运行:c4=10 + +​ int c4=c3++; c3=11 + +a+=b 转换a=a+b + + + +关系运算符就是比大小:比完的结果只能是布尔值 真或假 + +等于== 大于> 大于等于>= 小于< 小于等于<= 不等于!= + + + +逻辑运算符 + +与(并且)& and 短路与&&前面是假的,后面整个都是假的 + +或(或者)| 短路||前面是真,后面整个都是真的(后一个就不执行) + +非 (不是)!相反 + +异或(两两不同)^ 两个不同为真,相同为假。 + + + +三元运算符 + +关系表达式?表达式1:表达式2 + +如果关系表达式为真,执行表达式1.关系表达式为假,执行表达式2. + +if else里的每个条件都是互相排斥的,只能有一个条件成立或者条件都不成立。 diff --git "a/09\346\233\271\346\255\243\346\263\242/untitled/src/had.java" "b/09\346\233\271\346\255\243\346\263\242/20221125.md" similarity index 96% rename from "09\346\233\271\346\255\243\346\263\242/untitled/src/had.java" rename to "09\346\233\271\346\255\243\346\263\242/20221125.md" index 0cbdbc071b7581901c36c8b3a99336c2071d1c4c..e811dbfed00bbe5b44c01b3f2c41100eff27b299 100644 --- "a/09\346\233\271\346\255\243\346\263\242/untitled/src/had.java" +++ "b/09\346\233\271\346\255\243\346\263\242/20221125.md" @@ -1,3 +1,4 @@ +```java public class had { public static void main(String[] args) { int a=20; @@ -10,3 +11,7 @@ public class had { } } +``` + + + diff --git "a/09\346\233\271\346\255\243\346\263\242/20221128.md" "b/09\346\233\271\346\255\243\346\263\242/20221128.md" new file mode 100644 index 0000000000000000000000000000000000000000..93f3700de2eb0c4e3a990a5d59623e548638d934 --- /dev/null +++ "b/09\346\233\271\346\255\243\346\263\242/20221128.md" @@ -0,0 +1,70 @@ +## 第一题 + +```java +import java.util.Scanner; + +public class lx { + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + System.out.println("请输入四位数的整数"); + int name=sc.nextInt(); + System.out.println("个位:"+name%10); + System.out.println("十位:"+name%100/10); + System.out.println("百位:"+name/100%10); + System.out.println("千位:"+name/1000); + + } +} +``` + + + +## 第二题 + +```java +import java.util.Scanner; + +public class dier { + public static void main(String[] args) { + System.out.println("查看摄氏温度转华氏温度请输入1,查看华氏温度转摄氏温度请输入2"); + Scanner s=new Scanner(System.in); + int i=0; + int ss=0; + int hs=0; + i=s.nextInt(); + if (i==1){ + System.out.println("请输入摄氏的温度"); + Scanner ssd=new Scanner(System.in); + ss=ssd.nextInt(); + hs=ss*9/5+32; + System.out.println(ss+"对应的华氏温度为:"+hs); + } else{ + System.out.println("请输入华氏的温度"); + Scanner hsd=new Scanner(System.in); + hs=hsd.nextInt(); + ss=(hs-32)*5/9; + System.out.println(hs+"对应的摄氏温度为:"+ss); + } + } +} +``` + +## 第三题 + +```java +import java.util.Scanner; + +public class disan { + public static void main(String[] args) { + System.out.println("请输入需要判断的年份"); + Scanner sc=new Scanner(System.in); + int nf= sc.nextInt(); + int nnf=nf%4; + if (nnf==0){ + System.out.println(nf+"是闰年"); + } else{ + System.out.println(nf+"不是闰年"); + } + } +} +``` \ No newline at end of file diff --git "a/09\346\233\271\346\255\243\346\263\242/20221130.md" "b/09\346\233\271\346\255\243\346\263\242/20221130.md" new file mode 100644 index 0000000000000000000000000000000000000000..f0ef7eee5953048ba9105925f12de62b5fcba8de --- /dev/null +++ "b/09\346\233\271\346\255\243\346\263\242/20221130.md" @@ -0,0 +1,129 @@ +## 第三题 + +```java +public class Z3 { + //利用三元运算符求任意三个数中最大者 【三元】 + public static void main(String[] args) { + int a = 55; + int b = 86; + int c = 77; + int d = a > b ? a : b; + int e = d > c ? d : c; + System.out.println("最大者是:"+e); + } +} +``` + +## 第四题 + +```java +import java.util.Scanner; +//若任意两数和是3的倍数或其中一个为3,则输出true,否者输出false 【断路或】 +public class Z4 { + public static void main(String[] args) { + System.out.println("请输入任意两个数:"); + Scanner sb1=new Scanner(System.in); + Scanner sb2=new Scanner(System.in); + double s1= sb1.nextDouble(); + double s2= sb2.nextDouble(); + double he=s1+s2; + if (0==he%3 || 3==s1 || 3==s2){ + System.out.println("srue"); + }else{ + System.out.println("false"); + } + } +} +``` + +## 第五题 + +```java +public class Z5 { + //1. 身高是具有遗传性的,子女的身高和父母的身高有一定的关系。假定,父母和子女的身高遗传关系如下: + //儿子身高(厘米)=(父亲身高+母亲身高) ×1.08÷2, + // 女儿身高(厘米)=(父亲身高×0.923+母亲身高) ÷2 + // 现有父亲身高177CM,母亲身高165CM。求子女身高分别预计为多少?【使用变量的定义和算术运算符完成本题】 + public static void main(String[] args) { + int fq = 177; + int mq = 165; + double ez = (int)(fq + mq) * 1.08 / 2; + double ne = (int)(fq * 0.923 + mq) / 2; + System.out.println("预计儿子身高为:" + ez + "厘米"); + System.out.println("预计身高为:" + ne + "厘米"); + } +} +``` + +## 第六题 + +```java +public class Z6 { + //红茶妹妹有21元钱,她攒了几天钱之后自己的钱比原来的两倍还多三块。 + // 绿茶妹妹有24元钱,她攒了几天钱之后自己的钱正好是原来的两倍。 + //- 那么红茶和绿茶现在的钱一样多,请问对么? + // 【使用赋值运算符和算术运算符计算各自的钱,使用比较运算符对比大小】 + public static void main(String[] args) { + int hcmm = 21; + int lcmm = 24; + int hc = hcmm * 2 + 3; + int lc =lcmm * 2; + if (hc == lc) { + System.out.println("红茶和绿茶现在的钱一样多是对的"); + } else { + System.out.println("红茶和绿茶现在的钱一样多是错的"); + } + } +} +``` + +## 第七题 + +```java +public class Z7 { + //小明想在食堂打包一份午饭,商家的优惠方式如下:鱼香肉丝单点24元, + // 油炸花生米单点8元,米饭单点3元。订单满30元8折优惠。鱼香肉丝优惠价16元, + // 但是优惠价和折扣不能同时使用。那么这个小伙要点这三样东西,最少要花多少钱? + // 【使用算术运算符、赋值运算符和三元运算符联合完成本题】 + public static void main(String[] args) { + //单点 + int yxrs = 24; + int hsm = 8; + int mf = 3; + //优惠价 + int yxrsyh = 16; + double a = yxrsyh + hsm + mf;//都单点。 + double b = (yxrs + hsm) * 0.8 + 3;//鱼香肉丝和花生米一起点使用打折,米饭单点。 + double c = (yxrs + hsm + mf) * 0.8;//全部一起点使用打折. + double n1 = a > b ? b : a; + double n2 = n1 > c ? c : n1; + System.out.println("小明要点这三样东西,最少要花"+n2+"元"); + } +} +``` + +## 第八题 + +```java +import java.util.Scanner; +//中国足球对战小日本足球 +public class xrbVSzg { + public static void main(String[] args) { + Scanner xrb=new Scanner(System.in); + System.out.println("输入小日本的得分"); + Scanner zg=new Scanner(System.in); + System.out.println("输入中国的得分"); + double gr= xrb.nextDouble(); + double zh= zg.nextDouble(); + if (zh%gr==0){ + System.out.println("啧啧啧"); + }else if (zh%gr==1){ + System.out.println("很好很好"); + }else if (zh%gr==2){ + System.out.println("请客吃海参"); + }else if(zh%gr>2){ + System.out.println("你在想什么呢?"); + } + } +} +``` \ No newline at end of file diff --git "a/09\346\233\271\346\255\243\346\263\242/bff301c9b9feefde719619c7b311e16.jpg" "b/09\346\233\271\346\255\243\346\263\242/bff301c9b9feefde719619c7b311e16.jpg" deleted file mode 100644 index a5f8d87092ef4e6fdcd9fef45f7f6aa9e0b155aa..0000000000000000000000000000000000000000 Binary files "a/09\346\233\271\346\255\243\346\263\242/bff301c9b9feefde719619c7b311e16.jpg" and /dev/null differ diff --git "a/09\346\233\271\346\255\243\346\263\242/untitled/.idea/.gitignore" "b/09\346\233\271\346\255\243\346\263\242/untitled/.idea/.gitignore" deleted file mode 100644 index 359bb5307e8535ab7d59faf27a7377033291821e..0000000000000000000000000000000000000000 --- "a/09\346\233\271\346\255\243\346\263\242/untitled/.idea/.gitignore" +++ /dev/null @@ -1,3 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml diff --git "a/09\346\233\271\346\255\243\346\263\242/untitled/.idea/misc.xml" "b/09\346\233\271\346\255\243\346\263\242/untitled/.idea/misc.xml" deleted file mode 100644 index 0e05be0c46a38055d8ff79d7eec37aba7f267245..0000000000000000000000000000000000000000 --- "a/09\346\233\271\346\255\243\346\263\242/untitled/.idea/misc.xml" +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git "a/09\346\233\271\346\255\243\346\263\242/untitled/.idea/modules.xml" "b/09\346\233\271\346\255\243\346\263\242/untitled/.idea/modules.xml" deleted file mode 100644 index 3007daed6a4d82eb6e1d037c710a00d300be5706..0000000000000000000000000000000000000000 --- "a/09\346\233\271\346\255\243\346\263\242/untitled/.idea/modules.xml" +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git "a/09\346\233\271\346\255\243\346\263\242/untitled/out/production/untitled/had.class" "b/09\346\233\271\346\255\243\346\263\242/untitled/out/production/untitled/had.class" deleted file mode 100644 index 256f029ee65bf4d14c42d767e0e1039e0556e877..0000000000000000000000000000000000000000 Binary files "a/09\346\233\271\346\255\243\346\263\242/untitled/out/production/untitled/had.class" and /dev/null differ diff --git "a/09\346\233\271\346\255\243\346\263\242/untitled/untitled.iml" "b/09\346\233\271\346\255\243\346\263\242/untitled/untitled.iml" deleted file mode 100644 index c90834f2d607afe55e6104d8aa2cdfffb713f688..0000000000000000000000000000000000000000 --- "a/09\346\233\271\346\255\243\346\263\242/untitled/untitled.iml" +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file