Official

C - AEIOU Editorial by sounansya


\(S\) の先頭の文字から順番に a, e, i, o, u をそれぞれ A, E, I, O, U に置き換え、それ以外はそのままにすれば良いです。

実装例(Python3)

s = input()
ans = ""
for c in s:
    if c == "a":
        ans += "A"
    elif c == "e":
        ans += "E"
    elif c == "i":
        ans += "I"
    elif c == "o":
        ans += "O"
    elif c == "u":
        ans += "U"
    else:
        ans += c
print(ans)

また、Python であれば replace 関数を用いることでこの処理は以下のように簡潔に書くこともできます。

実装例(Python3)

s = input()
for c in "AEIOU":
    s = s.replace(c.lower(), c)
print(s)

posted:
last update: