当前位置:网站首页>LV1 tire pressure monitoring
LV1 tire pressure monitoring
2022-07-04 01:57:00 【HBUcs2020】
At first, the topic was too complicated ,max,ave Got a bunch of definitions ,
Examine the subject carefully , This question is not difficult
Code :
#include<iostream>
using namespace std;
#include<set>
#include<vector>
int main()
{
// Four tire pressures , Minimum alarm tire pressure , Tire pressure difference
// If one of the four is different from the maximum 》 Tire pressure difference , The second case
// If big with one , Then check all
// multiset<int>s; // Default ascending sort
// for(int i=0; i<4; i++)
// {
// int n;
// cin>>n;
// s.insert(n);
// }
// int ave,max;
// cin>>ave>>max;
// int num=0;
// if((a[3]-a[0])>max)
// {
// num++;
// if((a[3]-a[1])>max)
// num++;
// }
// if(num==0)
vector<int>v;
int maxnum=0;
for(int i=0;i<4;i++)
{
int n;
cin>>n;
v.push_back(n);
if(n>maxnum)
maxnum=n;
//maxnum=max(maxnnum,n);
}
int ave,max;
cin>>ave>>max;
//int max1=0,max2=0,num1,num2;
int num1=0,index;
for(int i=0;i<4;i++)
{
// int n=v[i]-ave;
// if(n>max2)
// {
// if(n>max1)
// {
// max1=n;
// num1=i;
// }
// else
// {
// max2=n;
// num2=i;
// }
// }
if(v[i]<ave||maxnum-v[i]>max)
{
num1++;
index=i;
}
}
if(num1>1)
cout<<"Warning: please check all the tires!"<<endl;
else if(num1==1)
printf("Warning: please check #%d!",index+1);
else
cout<<"Normal"<<endl;
return 0;
}
subject :
There is a system in the car to monitor the tire pressure of four wheels at any time , If the four tire pressures are not very balanced , It may have a serious impact on the driving .

Let's put four wheels —— Left front wheel 、 Right front wheel 、 Right rear wheel 、 Left rear wheel —— The serial number is 1、2、3、4. Please write a monitoring program , Monitor the tire pressure of the four wheels at any time , And give correct alarm information . The alarm rules are as follows :
- If the error between the pressure values of all tires and the maximum of them is within a given threshold , And the tire pressure shall not be lower than the minimum alarm tire pressure set by the system , It indicates that the situation is normal , Don't call the police ;
- If the error between the pressure value of a tire and the maximum value of them exceeds the threshold , Or lower than the minimum alarm tire pressure set by the system , Then you should not only call the police , And give the exact location of the tire that may leak ;
- If there are two or more tires, the error between the pressure value and the maximum value of them exceeds the threshold , Or lower than the minimum alarm tire pressure set by the system , The alarm requires all tires to be checked .
Input format :
Enter... On one line 6 individual [0, 400] Range of integers , In turn 1~4 The tire pressure of tire No 、 Minimum alarm tire pressure 、 And the threshold of tire pressure difference .
Output format :
The corresponding information is given according to the entered tire pressure value :
- If you don't have to call the police , Output
Normal; - If a tire needs an alarm , Output
Warning: please check #X!, amongXIt's the number of the tyre in question ; - Check all tires if necessary , Output
Warning: please check all the tires!.
sample input 1:
242 251 231 248 230 20
sample output 1:
Normal
sample input 2:
242 251 232 248 230 10
sample output 2:
Warning: please check #3!
sample input 3:
240 251 232 248 240 10
sample output 3:
Warning: please check all the tires!边栏推荐
- Idea if a class cannot be found, it will be red
- What are the main investment products of bond funds and what are they
- Reading notes - learn to write: what is writing?
- The reasons why QT fails to connect to the database and common solutions
- A. Min Max Swap
- Gee: create a new feature and set corresponding attributes
- Setting function of Jerry's watch management device [chapter]
- 2022 R2 mobile pressure vessel filling certificate examination and R2 mobile pressure vessel filling simulation examination questions
- G3 boiler water treatment registration examination and G3 boiler water treatment theory examination in 2022
- Conditional test, if, case conditional test statements of shell script
猜你喜欢

Douban scoring applet Part-3

Feign implements dynamic URL

JVM performance tuning and practical basic theory - medium

Lightweight Pyramid Networks for Image Deraining

Huawei cloud micro certification Huawei cloud computing service practice has been stable

Will the memory of ParticleSystem be affected by maxparticles

Bacteriostatic circle scanning correction template

Remember a lazy query error

Audio resource settings for U3D resource management
![When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]](/img/fb/7d4a026260f8817460cc67f06e49ae.jpg)
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
随机推荐
MySQL statement learning record
Do you know the eight signs of a team becoming agile?
Flex flexible layout, box in the middle of the page
Writeup (real questions and analysis of ciscn over the years) of the preliminary competition of national college students' information security competition
Why can't it run (unresolved)
Learn these super practical Google browser skills, girls casually flirt
PMP daily three questions (February 14, 2022)
Small program graduation project based on wechat examination small program graduation project opening report function reference
Is Shengang securities company as safe as other securities companies
Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
A fan summed up so many interview questions for you. There is always one you need!
Portable two-way radio equipment - current market situation and future development trend
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
Rearrangement of tag number of cadence OrCAD components and sequence number of schematic page
Hash table, string hash (special KMP)
Description of setting items of Jerry [chapter]
Introduction to graphics: graphic painting (I)
TP5 automatic registration hook mechanism hook extension, with a complete case
High level application of SQL statements in MySQL database (I)
[turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration