周期変化の問題
問題概要
高橋君の住む街では、天気が "Sunny", "Cloudy", "Rainy" をこの順に周期的に繰り返す。
ある日の天気を表す文字列 が与えられるので、その次の日の天気を表す文字列を出力せよ。
解法
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; }