L1-069 胎压监测 (15 分)-PAT 团体程序设计天梯赛 GPLT

解题思路:找到四个轮胎中胎压最大的,然后根据是否其余轮胎胎压与其是否相差超过阈值,或低于最低胎压,得到有问题轮胎的个数

#include
using namespace std;
int main(){
    int wheel[4],low,diff,index,max,ans=0;
    cin>>wheel[0]>>wheel[1]>>wheel[2]>>wheel[3]>>low>>diff;
    max = *max_element(wheel, wheel + 4);
    for(int i=0;i<4;i++){
        if((max-wheel[i])>diff||wheel[i]=2)
        cout<<"Warning: please check all the tires!";
}

运行结果:

L1-069 胎压监测 (15 分)-PAT 团体程序设计天梯赛 GPLT_第1张图片

 

你可能感兴趣的:(团队程序设计天梯赛,c++,算法,开发语言)