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

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

AtCoder ABC 138 A - Red or Not (灰色, 100 点)

if 文の練習問題!

問題概要

整数  s と文字列  s が与えられる。

 s が 3200 以上ならば  s を答えて、3200 未満ならば "red" と答えよ。

解法

if 文を用いて処理を分岐すれば OK

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

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}