誕生日ケーキには、年齢の数だけろうそくを立てます。1 歳から age 歳までに使ったろうそくの数を求める total_candles(age) を書きましょう。age が 0 なら 0 本です。
total_candles(3)→6total_candles(1)→1int total_candles(int age)int total_candles(int age) {
int total = 0;
for (int year = 1; year <= age; year++) {
// ここにコードを書く:この年のろうそくを total に足す
}
return total;
}
実行すると例で試せます。よさそうなら提出しましょう。