当前位置:网站首页>L1-069 胎压监测 (15 分)
L1-069 胎压监测 (15 分)
2022-04-22 22:19:00 【WTXYL】
小轿车中有一个系统随时监测四个车轮的胎压,如果四轮胎压不是很平衡,则可能对行车造成严重的影响。
让我们把四个车轮 —— 左前轮、右前轮、右后轮、左后轮 —— 顺次编号为 1、2、3、4。本题就请你编写一个监测程序,随时监测四轮的胎压,并给出正确的报警信息。报警规则如下:
- 如果所有轮胎的压力值与它们中的最大值误差在一个给定阈值内,并且都不低于系统设定的最低报警胎压,则说明情况正常,不报警;
- 如果存在一个轮胎的压力值与它们中的最大值误差超过了阈值,或者低于系统设定的最低报警胎压,则不仅要报警,而且要给出可能漏气的轮胎的准确位置;
- 如果存在两个或两个以上轮胎的压力值与它们中的最大值误差超过了阈值,或者低于系统设定的最低报警胎压,则报警要求检查所有轮胎。
输入格式:
输入在一行中给出 6 个 [0, 400] 范围内的整数,依次为 1~4 号轮胎的胎压、最低报警胎压、以及胎压差的阈值。
输出格式:
根据输入的胎压值给出对应信息:
- 如果不用报警,输出
Normal; - 如果有一个轮胎需要报警,输出
Warning: please check #X!,其中X是出问题的轮胎的编号; - 如果需要检查所有轮胎,输出
Warning: please check all the tires!。
输入样例 1:
242 251 231 248 230 20
输出样例 1:
Normal
输入样例 2:
242 251 232 248 230 10
输出样例 2:
Warning: please check #3!
输入样例 3:
240 251 232 248 240 10
输出样例 3:
Warning: please check all the tires!
代码:
#include <iostream>
using namespace std;
const int N = 5;
int a[N], minP, maxP = -1, yu;
int main(){
for(int i = 1; i < N; i ++){
cin >> a[i];
maxP = maxP > a[i] ? maxP : a[i];
}
cin >> minP >> yu;
int cnt = 0, p;
for(int i = 1; i < N; i ++)
if(a[i] < minP || maxP - a[i] > yu){
p = i;
cnt ++;
}
if(cnt == 0) cout << "Normal";
else if(cnt == 1) cout << "Warning: please check #" << p << "!";
else cout << "Warning: please check all the tires!";
}
版权声明
本文为[WTXYL]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_46891900/article/details/124318500
边栏推荐
- The PMP certificate has expired. Is it necessary to renew it
- R语言数据分析从入门到高级:(九)数据清洗技巧之数据表连接大全
- USPS数据集_kmeans使用总结
- jsp的form表单提交给servlet但js失效问题
- Advanced multithreading (6) -- locking mechanism
- GBase 8s V8.8 SQL 指南:教程-6.2.1(3)
- MySQL表的增删改查(进阶)
- MTP管理课者养成计划-第1天学习笔记
- Enter a line of characters, separated by a space between words, and count how many words there are
- MySql内置函数
猜你喜欢

In the future, platofarm's ecological pass can be logged into bitmart and other four major global platforms

js的正则表达式

多线程进阶(八)----线程池

动态规划:分组背包问题

Centos7安装mysql

GBase 8s V8.8 SQL 指南:教程-6.2.1(2)

MySQL表的增删改查(进阶)

Llvm learning (I) - getting to know llvm

Regular expression of JS

行人重识别综述之Person Re-identification:Past, Present and Future
随机推荐
Quickly calculate the number of divisors -- from basic to advanced
O0 O1 O2 O3 optimization principle
给复杂的数组结构数据换key
做到与做好,国产引擎 Cocos 如何丛林突围?
Rasa's new training method of Rasa
jsp的form表单提交给servlet但js失效问题
repeat_map mp.find() + mp.erase()
数组去重-基本数据类型
3.20-4.20 summary of recent project experience
Advanced multithreading (8) -- thread pool
CAS统一身份认证(三):外部独立配置
fastadmin 动态赋值下拉框
Advanced multithreading (6) -- locking mechanism
10万开发者涌入“酷应用”,钉钉押注场景化
多线程进阶(六)----锁机制
【洛谷】P1162 填涂颜色(bfs)
Knowledge map opening notes
41.0:GemBox. Spreadsheet|. Document|. Pdf|. Presentation
fastadmin 跳转后限定搜索条件
appinventor拓展开发