返回列表 發帖

008 switch 成績分級程式

成績分級程式
90分~100分  優
  80分~89分  甲
  70分~79分  乙
  60分~69分  丙
    0分~59分  丁

  1. #include<iostream>
  2. #include<cstdlib>

  3. using namespace std;
  4. int main()
  5. {
  6.         int x;
  7.         cout << "請輸入您的成績";
  8.         cin >> x;
  9.         x= x/10;
  10.         switch (x)
  11.         {
  12.         case 10:case 9:
  13.                 cout << "優";
  14.                 break;
  15.         case 8:
  16.                 cout << "甲";
  17.                 break;
  18.         case 7:
  19.                 cout << "乙";
  20.                 break;
  21.         case 6:
  22.                 cout << "丙";
  23.                 break;
  24.         case 5:case 4:case 3:case 2:case 1:case 0:
  25.                 cout << "丁";
  26.                 break;
  27.         default:
  28.                 cout << "很皮喔!";
  29.                 break;
  30.         }
  31.         return 0;
  32. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>

  3. using namespace std;
  4. int main()
  5. {
  6.         int x;
  7.         cout << "請輸入您的成績";
  8.         cin >> x;
  9.         x= x/10;
  10.         switch (x)
  11.         {
  12.         case 10:
  13.                 cout << "優";
  14.                 break;
  15.         case 9:
  16.                 cout << "優";
  17.                 break;
  18.         case 8:
  19.                 cout << "甲";
  20.                 break;
  21.         case 7:
  22.                 cout << "乙";
  23.                 break;
  24.         case 6:
  25.                 cout << "丙";
  26.                 break;
  27.         case 5:
  28.                 cout << "丁";
  29.                 break;
  30.         case 4:
  31.                 cout << "丁";
  32.                 break;
  33.         case 3:
  34.                 cout << "丁";
  35.                 break;
  36.         case 2:
  37.                 cout << "丁";
  38.                 break;
  39.         case 1:
  40.                 cout << "丁";
  41.                 break;
  42.         case 0:
  43.                 cout << "丁";
  44.                 break;
  45.         default:
  46.                 cout << "很皮喔!";
  47.                 break;
  48.         }
  49.         return 0;
  50. }
複製代碼

TOP

本帖最後由 林宇翔 於 2014-3-8 15:04 編輯
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int x;
  7.         cout << "請輸入你的分數:";
  8.         cin >> x;
  9.         x = x / 10 ;
  10.         switch(x)
  11.         {
  12.         case 10:
  13.         case 9:
  14.                 cout << "優";
  15.                 break;
  16.         case 8:
  17.                 cout << "甲";
  18.                 break;
  19.         case 7:
  20.                 cout << "乙";
  21.                 break;
  22.         case 6:
  23.                 cout << "丙";
  24.                 break;
  25.         case 5: case 4:case 3:case 2:case 1:case 0:
  26.                 cout << "丁";
  27.                 break;
  28.         default:
  29.                 cout << "找死喔";         
  30.         }
  31.         system ("pause");
  32.         return 0;
  33. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>

  3. using namespace std;
  4. int main()
  5. {
  6.         int x;
  7.         cout << "請輸入您的成績";
  8.         cin >> x;
  9.         x= x/10;
  10.         switch (x)
  11.         {
  12.                 case 10:
  13.                 cout << "優";
  14.                 break;
  15.                 case 9:
  16.                 cout << "優";
  17.                 break;
  18.                 case 8:
  19.                 cout << "甲";
  20.                 break;
  21.                 case 7:
  22.                 cout << "乙";
  23.                 break;
  24.                 case 6:
  25.                 cout << "丙";
  26.                 break;
  27.                 case 5:
  28.                 cout << "丁";
  29.                 break;
  30.                 case 4:
  31.                 cout << "丁";
  32.                 break;
  33.                 case 3:
  34.                 cout << "丁";
  35.                 break;
  36.                 case 2:
  37.                 cout << "丁";
  38.                 break;
  39.                 case 1:
  40.                 cout << "丁";
  41.                 break;
  42.                 case 0:
  43.                 cout << "丁";
  44.                 break;
  45.                 default:
  46.                 cout << "很皮喔!";
  47.                 break;
  48.         }
  49.         return 0;
  50. }
複製代碼

TOP

返回列表