けんちょんの競プロ精進記録

競プロの精進記録や小ネタを書いていきます

AtCoder ABC 141 A - Weather Prediction (灰色, 100 点)

周期変化の問題

問題概要

高橋君の住む街では、天気が "Sunny", "Cloudy", "Rainy" をこの順に周期的に繰り返す。

ある日の天気を表す文字列  S が与えられるので、その次の日の天気を表す文字列を出力せよ。

解法

if 文を用いて丁寧に実装しよう。

#include <bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}