B3825 题解

· · 题解

很简单,就是考察分支结构。
如果 x\in[0,10),输出 Drizzle
如果 x\in[10,25),输出 Moderate Rain
如果 x\in[25,50),输出 Heavy Rain
如果 x\ge 50,输出 Torrential Rain
特别地,当 h=1 时:如果 x\ge20 输出 YES,否则输出 NO。若 h=24,则不输出。

#include <bits/stdc++.h>

using namespace std;

int x, h; 

int main() {
    cin >> x >> h;
    if (x < 10) cout << "Drizzle";
    else if (x >= 10 && x < 25) cout << "Moderate Rain";
    else if (x >= 25 && x < 50) cout << "Heavy Rain";   
    else if (x >= 50) cout << "Torrential Rain";
    if (h == 1) {
        if (x >= 20) cout << '\n' << "YES";
        else cout << '\n' << "NO";
    }
    return 0;
}