點單機上按一個字母:a 是 Milk tea,b 是 Coffee,c 是 Soda。a 和 c 都寫好了,補上 b 那一條。這次按的是 b。
Coffee
#include <iostream>
using namespace std;
int main() {
char key = 'b';
switch (key) {
case 'a':
cout << "Milk tea" << endl;
break;
// 在這裡寫:按 b 的時候顯示 Coffee
case 'c':
cout << "Soda" << endl;
break;
}
return 0;
}
寫好了先點「執行」試試示例,沒問題再點「提交」。