寫 shout(s):把 s 裡的字母都變成大寫,最後加一個 !。不是字母的不變。
shout("hi")→'HI!'shout("")→'!'string shout(string s)#include <string>
#include <cctype>
using namespace std;
string shout(string s) {
for (char &ch : s) {
// 在這裡寫:把 ch 變成大寫
}
return s + "!";
}
寫好了先點「執行」試試示例,沒問題再點「提交」。