返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5.    
  6.     int score;
  7.     cout<<"請輸入你的成績:";
  8.     cin>>score;
  9.    
  10.     switch(score){
  11.     case 90 ... 100:
  12.         cout<<"優等"<<endl;  
  13.         break;
  14.     case 80 ... 89:
  15.         cout<<"甲等"<<endl;  
  16.         break;
  17.     case 70 ... 79:
  18.         cout<<"乙等"<<endl;  
  19.         break;  
  20.     case 60 ... 69:
  21.         cout<<"丙等"<<endl;  
  22.         break;   
  23.     case 0 ... 59:
  24.         cout<<"不及格"<<endl;  
  25.         break;
  26.     default:
  27.         cout<<"輸入錯誤"<<endl;
  28.         break;
  29.     }
  30.    
  31.     system("pause");
  32.     return 0;   
  33. }
複製代碼

TOP

返回列表