奶茶分三種杯:'S' 10 元、'M' 12 元、'L' 15 元。寫 cup_price(size),size 是這三個字母中的一個,返回價錢。小杯和大杯已經寫好,就差中杯。
cup_price('S')→10cup_price('M')→12int cup_price(char size)int cup_price(char size) {
if (size == 'S') {
return 10;
}
// 在這裡寫:size 是 'M',就返回 12
return 15;
}
寫好了先點「執行」試試示例,沒問題再點「提交」。