- #include<iostream>
- #include<cstdlib>
- using namespace std;
- main ()
- {
- while (true)
- {
- int score;
-
- cout<<"請輸入一個分數(0~100):";
- cin>>score;
-
- int level= (int)(score/10);
- switch(level)
- {
- case 10:
- case 9:
- cout<<"A"<<endl;
- break;
- case 8:
- cout<<"B"<<endl;
- break;
- case 7:
- cout<<"C"<<endl;
- break;
- case 6:
- cout<<"D"<<endl;
- break;
- default:
- cout<<"不及格"<<endl;
- }
- system ("pause");
- }
- return 0;
- }
複製代碼 |