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

TOP

返回列表