当前位置:网站首页>L1-069 tire pressure monitoring (15 points)

L1-069 tire pressure monitoring (15 points)

2022-06-10 16:47:00 Liabilities between persons^

L1-069 Tire pressure monitoring (15 branch )

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 .

 Insert picture description here
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!, among X
  • 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!
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>

using namespace std;
typedef long long ll;
const int N=10010;

int main()
{
    
	int a[4], x, y;
	int maxx = 0;
	for(int i = 0; i < 4; i ++ )
	{
    
		cin >> a[i];
		maxx = max(a[i], maxx);
	}
	cin >> x >> y;
	int flag = 0;
	int res;
	for(int i = 0; i < 4; i ++ )
	{
    
		if((maxx - a[i]) <= y && a[i] >= x)
			continue;
		else
		{
    
			flag ++ ;
			res = i;
		}
	}
	if(flag == 0) cout << "Normal" << endl;
	else if(flag == 1) printf("Warning: please check #%d!", res + 1);
	else cout << "Warning: please check all the tires!" << endl; 
	return 0;
}



原网站

版权声明
本文为[Liabilities between persons^]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020951008822.html