当前位置:网站首页>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!
, amongX
It'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!
边栏推荐
- String & memory function (detailed explanation)
- Sequence sorting of basic exercises of test questions
- Is Shengang securities company as safe as other securities companies
- Three layer switching ②
- Human resource management online assignment
- All metal crowns - current market situation and future development trend
- 51 single chip microcomputer timer 2 is used as serial port
- The latest analysis of hoisting machinery command in 2022 and free examination questions of hoisting machinery command
- String hash, find the string hash value after deleting any character, double hash
- Override and virtual of classes in C #
猜你喜欢
Pytoch residual network RESNET
Audio resource settings for U3D resource management
Douban scoring applet Part-3
Conditional statements of shell programming
Hbuilder link Xiaoyao simulator
Three layer switching ①
Will the memory of ParticleSystem be affected by maxparticles
Infiltration learning diary day19
Small program graduation project based on wechat reservation small program graduation project opening report reference
JVM performance tuning and practical basic theory - medium
随机推荐
Huawei cloud micro certification Huawei cloud computing service practice has been stable
QML add gradient animation during state transition
Customize redistemplate tool class
[typora installation package] old typera installation package, free version
In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
G3 boiler water treatment registration examination and G3 boiler water treatment theory examination in 2022
From the 18th line to the first line, the new story of the network security industry
Description of setting items of Jerry [chapter]
2022 R2 mobile pressure vessel filling certificate examination and R2 mobile pressure vessel filling simulation examination questions
Maximum entropy model
JVM performance tuning and practical basic theory - medium
A. Min Max Swap
Three layer switching ②
Lightweight Pyramid Networks for Image Deraining
Containerization technology stack
High level application of SQL statements in MySQL database (I)
2020-12-02 SSM advanced integration Shang Silicon Valley
Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
Small program graduation project based on wechat reservation small program graduation project opening report reference
The contact data on Jerry's management device supports reading and updating operations [articles]