ピアノ練習アプリは曲ごとに点数を付けます。90 点以上ならスター 3 つ、70 点以上なら 2 つ、50 点以上なら 1 つ、それより下は 0 です。n 曲分のスターの合計を返す stars_earned(scores, n) を書きましょう。曲がなければ 0 です。
stars_earned({95, 72, 40}, 3)→5stars_earned({50}, 1)→1int stars_earned(int scores[], int n)int stars_earned(int scores[], int n) {
int stars = 0;
for (int i = 0; i < n; i++) {
// ここにコードを書く:この点数に応じて stars に 3、2、1 を足すか、何も足さない
}
return stars;
}
実行すると例で試せます。よさそうなら提出しましょう。