From 7a7a66c0ab0274ff6fe97a5223a5dcd88aa70841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=B2=9B=E4=B8=9C?= <2409237500@qq.com> Date: Thu, 30 Mar 2023 23:35:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?MySQL=E7=9A=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7\347\224\260\346\262\233\344\270\234.txt" | 4 + ...21\347\224\260\346\262\233\344\270\234.md" | 29 +++ ...24\347\224\260\346\262\233\344\270\234.md" | 115 +++++++++ ...05\347\224\260\346\262\233\344\270\234.md" | 228 ++++++++++++++++++ ...07\347\224\260\346\262\233\344\270\234.md" | 77 ++++++ ...10\347\224\260\346\262\233\344\270\234.md" | 46 ++++ 6 files changed, 499 insertions(+) create mode 100644 "35\347\224\260\346\262\233\344\270\234/02.17\347\224\260\346\262\233\344\270\234.txt" create mode 100644 "35\347\224\260\346\262\233\344\270\234/02.21\347\224\260\346\262\233\344\270\234.md" create mode 100644 "35\347\224\260\346\262\233\344\270\234/02.24\347\224\260\346\262\233\344\270\234.md" create mode 100644 "35\347\224\260\346\262\233\344\270\234/03.05\347\224\260\346\262\233\344\270\234.md" create mode 100644 "35\347\224\260\346\262\233\344\270\234/03.07\347\224\260\346\262\233\344\270\234.md" create mode 100644 "35\347\224\260\346\262\233\344\270\234/03.10\347\224\260\346\262\233\344\270\234.md" diff --git "a/35\347\224\260\346\262\233\344\270\234/02.17\347\224\260\346\262\233\344\270\234.txt" "b/35\347\224\260\346\262\233\344\270\234/02.17\347\224\260\346\262\233\344\270\234.txt" new file mode 100644 index 0000000..8e197fa --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234/02.17\347\224\260\346\262\233\344\270\234.txt" @@ -0,0 +1,4 @@ +数据库class3 +表student +字段:学号,姓名,性别,爱好,住址,联系方式,邮箱,QQ号 +并新增一条自己的记录。 \ No newline at end of file diff --git "a/35\347\224\260\346\262\233\344\270\234/02.21\347\224\260\346\262\233\344\270\234.md" "b/35\347\224\260\346\262\233\344\270\234/02.21\347\224\260\346\262\233\344\270\234.md" new file mode 100644 index 0000000..7da1125 --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234/02.21\347\224\260\346\262\233\344\270\234.md" @@ -0,0 +1,29 @@ +```MySQL +CREATE DATABASE test01_company CHARSET gbk; +USE test01_company ; +CREATE TABLE offices( + officeCode int, + city varchar(30), + address varchar(50), + country varchar(30), + postalCode varchar(25) +); +create table employees( + empNum int, + lastName varchar(50), + firstName varchar(50), + mobile varchar(25), + `code` int, + jobTitle varchar(50), + birth date, + Note varchar(255), + Sex varchar(5) +); +ALTER TABLE employees MODIFY mobile varchar(25) AFTER `code`; +ALTER TABLE employees CHANGE birth birthday DATE; +ALTER TABLE employees MODIFY Sex char(1); +ALTER TABLE employees DROP COLUMN note; +ALTER TABLE employees ADD COLUMN favoriate_activity varchar(100); +ALTER TABLE employees RENAME TO employees_info; +``` + diff --git "a/35\347\224\260\346\262\233\344\270\234/02.24\347\224\260\346\262\233\344\270\234.md" "b/35\347\224\260\346\262\233\344\270\234/02.24\347\224\260\346\262\233\344\270\234.md" new file mode 100644 index 0000000..a5b4b6e --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234/02.24\347\224\260\346\262\233\344\270\234.md" @@ -0,0 +1,115 @@ +## 第1题:员工表 + +```mysql +drop table if exists `employee`; +#创建employee表 +CREATE TABLE employee( + id INT, + `name` VARCHAR(20), + sex VARCHAR(20), + tel VARCHAR(20), + addr VARCHAR(50), + salary FLOAT +); + +#添加信息 +INSERT INTO employee(id,`name`,sex,tel,addr,salary)VALUES +(10001,'张一一','男','13456789000','广东韶关',10010.58), +(10002,'刘小红','女','13454319000','广东江门',12010.21), +(10003,'李四','男','0751-1234567','广东佛山',10040.11), +(10004,'刘小强','男','0755-5555555','广东深圳',15010.23), +(10005,'王艳','男',NULL,'广东广州',14050.16); +``` + + + +| **id** | **name** | **sex** | **tel** | **addr** | **salary** | +| ------ | -------- | ------- | ------------ | -------- | ---------- | +| 10001 | 张一一 | 男 | 13456789000 | 广东韶关 | 10010.58 | +| 10002 | 刘小红 | 女 | 13454319000 | 广东江门 | 12010.21 | +| 10003 | 李四 | 男 | 0751-1234567 | 广东佛山 | 10040.11 | +| 10004 | 刘小强 | 男 | 0755-5555555 | 广东深圳 | 15010.23 | +| 10005 | 王艳 | 女 | NULL | 广东广州 | 14050.16 | + +**要求1:**查询出薪资在12000~13000之间的员工信息。 + +**要求2:**查询出姓“刘”的员工的工号,姓名,家庭住址。 + +**要求3:**将“李四”的家庭住址改为“广东韶关” + +**要求4:**查询出名字中带“小”的员工 + +**要求5:**查询出薪资高于11000的男员工信息 + +**要求6:**查询没有登记电话号码的员工 + +**要求7:**查询薪资高于12000或者家是广东深圳、广州的男员工 + +**要求8:**查询每个员工的年薪,显示“姓名、年薪” + +```mysql + +``` + +## 第2题:国家信息表 + +countries_info表中存储了国家名称、所属大陆、面积、人口和 GDP 值。 + +```mysql +DROP TABLE IF EXISTS `countries_info`; +CREATE TABLE `countries_info`( + `name` VARCHAR(100), + `continent` VARCHAR(100), + `area` INT, + population INT, + gdp BIGINT +); + +INSERT INTO countries_info VALUES +('Afghanistan','Asia',652230,25500100,20343000000), +('Albania','Europe',28748,2831741,12960000000), +('Algeria','Africa',2381741,37100000,188681000000), +('Andorra','Europe',468,78115,3712000000), +('Angola','Africa',1246700,20609294,100990000000); +``` + +表数据样例: + +```mysql ++-------------+-----------+---------+------------+--------------+ +| name | continent | area | population | gdp | ++-------------+-----------+---------+------------+--------------+ +| Afghanistan | Asia | 652230 | 25500100 | 20343000000 | +| Albania | Europe | 28748 | 2831741 | 12960000000 | +| Algeria | Africa | 2381741 | 37100000 | 188681000000 | +| Andorra | Europe | 468 | 78115 | 3712000000 | +| Angola | Africa | 1246700 | 20609294 | 100990000000 | ++-------------+-----------+---------+------------+--------------+ +``` + +**要求1:** 查询大国 的国家名称、人口和面积。 + +如果一个国家满足下述两个条件之一,则认为该国是 大国 : + +- 面积至少为 300万平方公里(即,3000000 km2) + +- 人口至少为 2500 万(即 25000000) + +**要求2:**查询属于亚洲的国家名称、所属大陆、面积、人口和 GDP 值 + +**要求3:**查询国土面积不足1万平方公里且人口不走10万人的国家信息 + +**要求4:**查询国家名字中包含“o“字母的国家信息 + +**要求5:**查询GDP值超过10000000000的国家信息 + +**要求6:**查询每个国家的人均贡献GDP值(GDP/人口总数)并显示为“国家名、人口、GDP值、人均贡献GDP值” + +**要求7:**查询人均贡献GDP值低于1000的国家信息。 + +**要求8:**查询每个国家的人均国土面积(面积/人口总数)并显示为“国家名、面积、人口、人均国土面积值” + +```mysql + +``` + diff --git "a/35\347\224\260\346\262\233\344\270\234/03.05\347\224\260\346\262\233\344\270\234.md" "b/35\347\224\260\346\262\233\344\270\234/03.05\347\224\260\346\262\233\344\270\234.md" new file mode 100644 index 0000000..fb279e7 --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234/03.05\347\224\260\346\262\233\344\270\234.md" @@ -0,0 +1,228 @@ +# 查询 + +1. 查询所有人的个人编号和个人简介 + + ```mysql + select id,aboutme from student; + ``` + + + +2. 查询所有公主 + + ```mysql + select * from student where sex = '公主'; + ``` + + + +3. 查询福建人 + + ```mysql + select * from stundent where address like = '%福建%'; + ``` + + + +4. 查询张姓人 + + ```mysql + select * from student where name like = '%张%'; + ``` + + + +5. 统计喜欢睡觉的人数 + + ```mysql + select count(*) from student where hobby like = '%睡觉%'; + ``` + + + +6. 查询所有学生的魅力值的平均值 + + ```mysql + select avg(meili) from student; + ``` + + + +7. 查询年龄最小的学生 + + ```mysql + select max(year(birthday)) from student ; + ``` + + + +8. 查询最受欢迎的游戏的名称 + + ```mysql + + ``` + + + +9. 按性别统计人数 + + ```mysql + select games + ``` + + + +10. 查询魅力值比陈欣威高的人的所有信息 + + ```mysql + + ``` + + + +11. 查询电话号码尾数是8的学生 + + ```mysql + + ``` + + + +12. 查询所有人的魅力总和 + + ```mysql + + ``` + + + +13. 查询没有人玩的游戏有哪些 + + ```mysql + + ``` + + + +14. 查询没有填邮箱的学生 + + ```mysql + + ``` + + + +15. 查询地址填写不规范的学生,没写省 + + ```mysql + + ``` + + + +16. 查询魅力值在60到100之间的学生 + + ``` + + ``` + + + +17. 查询邮箱和微信都没写的学生 + + ``` + + ``` + + + +18. 查询下个月过生日的学生 + + ``` + + ``` + + + +19. 查询邮箱或微信没写的学生 + + ``` + + ``` + + + +20. 查询男生比女生多了几个 + + ``` + + ``` + + + +21. 查询不是QQ邮箱的学生 + + ``` + + ``` + + + +22. 按魅力值由低到高查询所有学生 + + ``` + + ``` + + + +23. 查询每个游戏的玩家人数,显示游戏编号和人数 + + ```mysql + select id,count(games.name) from student inner join games on game_id = games.id where (select count(games.id) from student inner join games on game_id = games.id) group by games.name ; + ``` + + + +24. 查询每个游戏的玩家人数,显示游戏编号,游戏名称和人数 + + ```mysql + select id,games.name,count(games.name) 人数 from student inner join games on game_id = games.id where (select count(games.id) from student inner join games on game_id = games.id) group by games.name ; + + ``` + + + +25. 查询每个游戏的玩家人数,显示游戏编号,游戏名称和人数,按人数由高到低排序 + + ```mysql + select id,games.name,count(games.name) from student inner join games on game_id = games.id where (select count(games.id) from student inner join games on game_id = games.id) group by games.name order by desc; + + ``` + + + +26. 查询每个游戏的玩家人数,显示游戏编号,游戏名称和人数,按人数由高到低排序,保留人数大于5的游戏 + + ```mysql + select id,games.name,count(games.name) from student inner join games on game_id = games.id where (select count(games.id) from student inner join games on game_id = games.id) group by games.name having games.name>5 order by desc; + + ``` + + + +27. 查询与郑弘晖是同乡的学生 + + ``` + + ``` + + + +28. 查询与黄诗龙是同乡的学生玩了的是哪些游戏,显示姓名和游戏名称 + + ``` + + ``` + + \ No newline at end of file diff --git "a/35\347\224\260\346\262\233\344\270\234/03.07\347\224\260\346\262\233\344\270\234.md" "b/35\347\224\260\346\262\233\344\270\234/03.07\347\224\260\346\262\233\344\270\234.md" new file mode 100644 index 0000000..a09e31c --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234/03.07\347\224\260\346\262\233\344\270\234.md" @@ -0,0 +1,77 @@ +```mysql +CREATE TABLE stuinfo( +stuNo VARCHAR(10), +stuName VARCHAR(10), +stuSex enum('男','女'), +stuAge int, +stuAddress VARCHAR(10), +stuSeat int +); + +CREATE TABLE stuExam( +examNo int, +stuNo VARCHAR(10), +writtenExam int, +labExam int +); + +CREATE TABLE stuMarks( +examNo int, +stuID VARCHAR(10), +score int +); + +INSERT INTO stuinfo VALUES('s2501','张秋利','男',20,'美国硅谷',1), +('s2502','李斯文','女',18,'湖北武汉',2), +('s2503','马文才','男',18,'湖南长沙',3), +('s2504','欧阳俊雄','女',21,'湖北武汉',4), +('s2505','梅超风','男',16,'湖北武汉',5), +('s2506','陈旋风','男',19,'美国硅谷',6); + +INSERT INTO stuExam VALUES(1,'s2501',50,70), +(2,'s2502',60,65), +(3,'s2503',86,70), +(4,'s2504',40,80), +(5,'s2505',70,85), +(6,'s2506',85,90); + +INSERT INTO stuMarks VALUES(1,'s2501',88), +(2,'s2501',92), +(3,'s2501',53), +(4,'s2502',60), +(5,'s2502',99), +(6,'s2503',82); + +-- 1.查询出年龄比班上平均年龄大的学生的信息 +SELECT * FROM stuinfo where stuAge>(SELECT AVG(stuAge) FROM stuinfo); +-- 2.查询出每个学生的学号,姓名,性别和选修课程的最高分(stuMarks) +SELECT stuNo 学号,stuName 姓名,stuSex 性别,max(score) 选修课程的最高分 FROM stuinfo LEFT JOIN stumarks ON stuinfo.stuNo=stumarks.stuID GROUP BY stuNo; +-- 3.查询出每个学生的学号,姓名,性别和考试平均分(stuExam) +SELECT stuinfo.stuNo 学号,stuName 姓名,stuSex 性别,(writtenExam+labExam)/2 考试平均分 FROM stuinfo LEFT JOIN stuexam on stuinfo.stuNo=stuexam.stuNo; +-- 4.查询性别是男并且年龄大于等于20的学生的信息(用两种方法实现:普通查询和子查询) +SELECT * FROM stuinfo WHERE stuSex='男' and stuAge>=20; +SELECT * FROM (SELECT * FROM stuinfo WHERE stuSex='男' and stuAge>=20) as ccc; +-- 5.查询出年龄比所有男生年龄都大的女生的信息 +SELECT * FROM stuinfo WHERE stuSex='女' and stuAge>(SELECT max(stuAge) FROM stuinfo WHERE stuSex='男'); +-- 6.查询出所有选修课程都及格的学生的信息 (stuMarks) +SELECT * FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE stuID not in(SELECT stuID FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score<60); +-- 7.查询出参加考试的学生的信息(用表连接,in二种方法做)(stuMarks) +SELECT * FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score is not NULL GROUP BY stuNo; +SELECT * FROM stuinfo WHERE stuNo in(SELECT stuNo FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score is not NULL GROUP BY stuNo); +-- 8.查询出没有参加考试的学生的信息(用表连接,in二种方法做)(stuMarks) +SELECT * FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score is null ; +SELECT * FROM stuinfo WHERE stuNo not in(SELECT stuNo FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score is not NULL GROUP BY stuNo); +-- 9.将有一门成绩成绩大于90分的学生的基本信息查询出来(stuMarks) +SELECT * FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score>90; +-- 10.查询出平均成绩在80分以上的学生的基本信息(stuMarks) +SELECT * FROM stuinfo LEFT JOIN stuexam on stuinfo.stuNo=stuexam.stuNo WHERE (writtenExam+labExam)/2>80; +-- 11.查询出某同学所有考试成绩比“张秋利”同学所有分数都高的学生基本信息(stuMarks) +SELECT * FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score>(SELECT MAX(score) FROM stumarks RIGHT JOIN stuinfo ON stuinfo.stuNo=stumarks.stuID WHERE stuName='张秋利'); +-- 12.查询出某同学所有考试成绩只需要比“张秋利”同学某个分数高的学生基本信息(stuMarks) +SELECT * FROM stuinfo LEFT JOIN stumarks on stuinfo.stuNo=stumarks.stuID WHERE score>any(SELECT score FROM stumarks RIGHT JOIN stuinfo ON stuinfo.stuNo=stumarks.stuID WHERE stuName='张秋利') and stuName!='张秋利'; +-- 13.查询班上比所有男生年龄都要大的女生的信息 +SELECT * FROM stuinfo WHERE stuSex='女' and stuAge>(SELECT max(stuAge) FROM stuinfo WHERE stuSex='男'); +-- 14.查询出只要比某个男生年龄大的女生的信息 +SELECT * FROM stuinfo WHERE stuSex='女' and stuAge>any(SELECT stuAge FROM stuinfo WHERE stuSex='男'); +``` + diff --git "a/35\347\224\260\346\262\233\344\270\234/03.10\347\224\260\346\262\233\344\270\234.md" "b/35\347\224\260\346\262\233\344\270\234/03.10\347\224\260\346\262\233\344\270\234.md" new file mode 100644 index 0000000..b89c50c --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234/03.10\347\224\260\346\262\233\344\270\234.md" @@ -0,0 +1,46 @@ +#1.查询所有的订单的订单的编号,订单日期,订购产品的类别和订购的产品名称,订购数量和订购单价 + +```mysql +select * from time left join wuping on time.orderID = wuping.orderid; +``` + +#2.查询订购数量大于50的订单的编号,订单日期,订购产品的类别和订购的产品名称 + +```mysql +select time.orderID , orderDate , itemType ,itemName from time left join wuping on time.orderID = wuping.orderid where theNumber > 50; +``` + +#3.查询所有的订单的订单的编号,订单日期,订购产品的类别和订购的产品名称,订购数量和订购单价以及订购总价 + +```mysql +select time.orderID , orderDate , itemType ,itemName , theNumber , theMoney , (theMoney*theNumber) 总价 from time left join wuping on time.orderID = wuping.orderid; +``` + +#4.查询单价大于等于5 或者 数量大于等于50的订单的订单的编号,订单日期,订购产品的类别和订购的产品名称,订购数量和订购单价以及订购总价 + +```mysql +select time.orderID , orderDate , itemType ,itemName , theNumber , theMoney , (theMoney*theNumber) 总价 from time left join wuping on time.orderID = wuping.orderid where theMoney >= 5 or theNumber >= 50; +``` + +#5.查询每个订单分别订购了几个产品,例如: + 编号 订购产品数 + 1 3 + 2 4 + +```mysql +select orderid 编号,count(*)订购产品数 from wuping GROUP BY orderid; +``` + +#6.查询每个订单里的每个类别的产品分别订购了几次和总数量,例如: + + 订单编号 产品类别 订购次数 总数量 + +```mysql +1 文具 2 82 +1 体育用品 1 1 +2 文具 2 56 +2 体育用品 1 2 +2 日常用品 1 20 + +select orderid,itemType,count(*),sum(theNumber) from wuping GROUP BY orderid,itemType; +``` \ No newline at end of file -- Gitee From 95f54129284ce4c74a0cbf25f278ecc9fd53877b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=B2=9B=E4=B8=9C?= <2409237500@qq.com> Date: Thu, 30 Mar 2023 23:51:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?java=E7=AC=AC=E4=B8=80=E6=AC=A1=E8=AF=BE?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...41\345\217\267\344\275\234\344\270\232.md" | 125 ++++++++++++++++++ ...42\345\217\267\344\275\234\344\270\232.md" | 33 +++++ 2 files changed, 158 insertions(+) create mode 100644 "35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2341\345\217\267\344\275\234\344\270\232.md" create mode 100644 "35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2342\345\217\267\344\275\234\344\270\232.md" diff --git "a/35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2341\345\217\267\344\275\234\344\270\232.md" "b/35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2341\345\217\267\344\275\234\344\270\232.md" new file mode 100644 index 0000000..f2cbad2 --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2341\345\217\267\344\275\234\344\270\232.md" @@ -0,0 +1,125 @@ +**1、判断一个字符数据是否是数字字符 ** + +**分析:** + +​ 1、需要判断一个字符是否是数字字符,首先需要提供一个字符数据 + +​ 2、字符是否为数字字符: 数字字符的范围 0 - 9 之间都属于数字字符,因此提供的字符只要大于或等于字符0,并且还要下于或等于字符9即可。 + +​ 3、判断完成之后,打印判断的结果。 + + + +```java +Scanner sc = new Scanner(System.in); +System.out.println("请输入数字"); +int s = sc.nextInt(); +boolean a = s >=0 && s<=9; +System.out.println(a); + +``` + +**2、判断一个字符数据是否是字母字符** + +**分析:** + +​ 1、需要判断一个字符是否是字母字符,首先需要提供一个字符数据 + +​ 2、字符是否为字母字符: 数字字符的范围 a - z 或者 A - Z 之间都属于字母字符,因此提供的字符只要大于或等于a,并且还要下于或等于z 或者 大于或等于A,并且还要下于或等于Z + +​ 3、判断完成之后,打印判断的结果。 + + + +**3、判断指定的年份是否为闰年,请使用键盘录入** + +**分析:** + +​ 1、闰年的判断公式为:能被4整除,但是不能被100整除 或者 能被400整除 + +​ 2、首先需要提供一个需要判断的年份,判断完成之后,打印判断的结果。 + + + +```java +Scanner sca = new Scanner(System.in); +System.out.println("请输入年份"); +int d = sca.nextInt(); +if (d%4==0 && d%100!=0 ||d%400==0){ + System.out.println("是闰年");} +else{ + System.out.println("不是闰年"); +} +``` + + + +**4、判断一个数字是否为水仙花数,请使用键盘录入** + +水仙花是指3位数字,表示的是每位上的数字的3次幂相加之后的和值和原数相等,则为水仙花数, + +**分析:** + +​ 如:153 ---> 1×1×*1 + 5*×5×*5 + 3×*3×3 = 153; 就是水仙花数 + +​ 1、首先需要提供一个需要判断的3位数字,因此需要一个数值 + +​ 2、判断的过程 + +​ a) 将3位数字的每一位上的数字拆分下来 + +​ b) 计算每位数字的3次幂之和 + +​ C) 用和值 和 原来的数字进行比较 + +​ D) 打印判断的比较结果即可 + + + +```java +Scanner scc = new Scanner(System.in); +System.out.println("请输入一个数"); +int g = scc.nextInt(); +if(g < 100 || g > 999){ + System.out.println(g+"这不是一个三位数"); +}else{ + int ge = g % 10; + int shi = g/10%10; + int bai = g/100; + if (ge*ge*ge+shi*shi*shi+bai*bai*bai == g){ + System.out.println(g+"这是一个水仙花数"); + }else{ + System.out.println(g+"这不是水仙花数"); + } +``` + + + +**5、判断一个5位数字是否为回文数,使用键盘录入** + +五位数的回文数是指最高位和最低位相等,次高位和次低位相等。如:12321  23732  56665 + +**分析:** + +​ 1、首先需要提供一个需要判断的5位数字,因此需要一个数值 + +​ 2、判断的过程 + +​ a) 将5位数字的万、千、十、个位数拆分出来 + +​ b) 判断比较万位和个位 、 千位和十位是否相等 + +​ 3、判断完成之后,打印判断的结果。 + +```java +Scanner scq = new Scanner(System.in); +System.out.println("请输入一个数"); +int y = scq.nextInt(); + +int ge1 = y%10; +int shi1 = y/10%10; +int bai1 = y/100; +int qian = y/1000%10; +int wan = y/10000; +``` + diff --git "a/35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2342\345\217\267\344\275\234\344\270\232.md" "b/35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2342\345\217\267\344\275\234\344\270\232.md" new file mode 100644 index 0000000..d95d352 --- /dev/null +++ "b/35\347\224\260\346\262\233\344\270\234java/03.30\347\224\260\346\262\233\344\270\2342\345\217\267\344\275\234\344\270\232.md" @@ -0,0 +1,33 @@ +```java +public class qa { + public qa() { + } + + public static void main(String[] args) { + double man = 184.68; + double woman = 164.1855; + System.out.println("儿子的身高是" + man + " 女儿的身高是" + woman); + int hongchayl = 21; + int lvchayl = 24; + int a = hongchayl * 2 + 3; + int b = lvchayl * 2; + if (a == b) { + System.out.println("正确"); + } else { + System.out.println("错误"); + } + + int yu = true; + int hua = true; + int mi = true; + double zheko = 28.0; + double youhu = 27.0; + if (zheko > youhu) { + System.out.println("最少要花" + zheko + "元"); + } else { + System.out.println("最少要花" + youhu + "元"); + } + + } +} +``` \ No newline at end of file -- Gitee