题目IDL1-069分数15分语言Java / Python题目描述小轿车中有一个系统随时监测四个车轮的胎压如果四轮胎压不是很平衡则可能对行车造成严重的影响。四个车轮编号左前轮(1)、右前轮(2)、右后轮(3)、左后轮(4)报警规则正常情况所有轮胎压力值与最大值误差在阈值内且都不低于最低报警胎压 → 不报警单个轮胎异常存在1个轮胎的压力值与最大值误差超过阈值或低于最低报警胎压 → 报警并指出具体轮胎编号多个轮胎异常存在2个或更多轮胎异常 → 报警要求检查所有轮胎输入格式一行6个整数范围[0, 400]1~4号轮胎胎压 最低报警胎压 胎压差阈值输出格式情况输出正常Normal单轮胎异常Warning: please check #X!多轮胎异常Warning: please check all the tires!输入样例242 251 231 248 230 20输出样例Normal解题思路求最大值遍历数组找出四个轮胎中的最大胎压判断异常对每个轮胎检查两个条件max - tire threshold→ 与最大值差距超过阈值tire minPressure→ 低于最低报警胎压计数输出根据异常轮胎数量决定输出格式代码实现Javaimportjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){ScannerscannernewScanner(System.in);int[]tiresnewint[4];for(inti0;i4;i){tires[i]scanner.nextInt();}intminPressurescanner.nextInt();// 最低报警胎压intthresholdscanner.nextInt();// 胎压差阈值// 找最大值intmaxtires[0];for(inti1;i4;i){if(tires[i]max){maxtires[i];}}// 检查异常轮胎intcount0;intlastAbnormal-1;for(inti0;i4;i){if(max-tires[i]threshold||tires[i]minPressure){count;lastAbnormali1;// 记录最后一个异常轮胎编号}}// 输出结果if(count0){System.out.println(Normal);}elseif(count1){System.out.println(Warning: please check #lastAbnormal!);}else{System.out.println(Warning: please check all the tires!);}}}Pythontireslist(map(int,input().split()))min_pressure,thresholdmap(int,input().split())# 找最大值max_pressuremax(tires)# 检查异常轮胎abnormal[]fori,tinenumerate(tires):ifmax_pressure-tthresholdortmin_pressure:abnormal.append(i1)# 轮胎编号从1开始countlen(abnormal)# 输出结果ifcount0:print(Normal)elifcount1:print(fWarning: please check #{abnormal[0]}!)else:print(Warning: please check all the tires!)运行验证样例输入样例输出结果242 251 231 248 230 20Normal✅242 251 232 248 230 10Warning: please check #3!✅240 251 232 248 240 10Warning: please check all the tires!✅样例1解释最大值251阈值20。231与251差20等于阈值248差3242差9都满足条件且≥230正常。样例2解释阈值10232与251差1910轮胎3异常。复杂度分析时间复杂度O(1)空间复杂度O(1)总结本题考察数组遍历和条件判断找出数组最大值遍历检查异常情况根据异常数量决定输出格式