- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a;
- re:
- cout<<"請輸入你的成績: ";
- cin>>a;
- switch(a)
- {
- case 90 ... 100:
- cout<<"優"<<endl;
- break;
- case 80 ...89:
- cout<<"甲"<<endl;
- break;
- case 70 ...79:
- cout<<"乙"<<endl;
- break;
- case 60 ...69:
- cout<<"丙"<<endl;
- break;
- case 0 ...59:
- cout<<"不及格"<<endl;
- break;
- default:
- cout<<"錯誤 "<<endl;
- }
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |