当前位置:网站首页>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!边栏推荐
- Chinese Mitten Crab - current market situation and future development trend
- C import Xls data method summary V (complete code)
- Hunan University | robust Multi-Agent Reinforcement Learning in noisy environment
- Write the first CUDA program
- Small program graduation project based on wechat reservation small program graduation project opening report reference
- Winter vacation daily question -- a single element in an ordered array
- Final consistency of MESI cache in CPU -- why does CPU need cache
- Jerry's update contact [article]
- Cancer biopsy instruments and kits - market status and future development trends
- Mongodb learning notes: command line tools
猜你喜欢

Three layer switching ②

Magical usage of edge browser (highly recommended by program ape and student party)

Remember another interview trip to Ali, which ends on three sides

Solution to the problem that jsp language cannot be recognized in idea

Openbionics robot project introduction | bciduino community finishing

Do you know the eight signs of a team becoming agile?

Openbionics exoskeleton project introduction | bciduino community finishing

Yyds dry goods inventory override and virtual of classes in C

Bacteriostatic circle scanning correction template

Huawei cloud micro certification Huawei cloud computing service practice has been stable
随机推荐
2022 electrician (elementary) examination question bank and electrician (elementary) simulation examination question bank
Huawei BFD and NQA
Notice on Soliciting Opinions on the draft of information security technology mobile Internet application (APP) life cycle security management guide
ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
C import Xls data method summary V (complete code)
Pyinstaller packaging py script warning:lib not found and other related issues
Neo4j learning notes
Life cycle of instance variables, static variables and local variables
Hash table, string hash (special KMP)
Hamburg University of Technology (tuhh) | intelligent problem solving as integrated hierarchical reinforcement learning
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
Install the pit that the electron has stepped on
A. Min Max Swap
Pyrethroid pesticide intermediates - market status and future development trend
Basic editing specifications and variables of shell script
Trading software programming
The difference between lambda expressions and anonymous inner classes
Reading notes - learn to write: what is writing?