Kodewick
開始學 →
入門←→0 / 86

大聲喊

#002入門toupper(ch)約 3 分鐘

寫 shout(s):把 s 裡的字母都變成大寫,最後加一個 !。不是字母的不變。

示例
shout("hi")→'HI!'
shout("")→'!'
函式string shout(string s)
main.cpp
#include <string>
#include <cctype>
using namespace std;

string shout(string s) {
    for (char &ch : s) {
        // 在這裡寫:把 ch 變成大寫
    }
    return s + "!";
}
Ctrl + Enter 也能執行
結果

寫好了先點「執行」試試示例,沒問題再點「提交」。