#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
re:
int score;
cout<<"請輸入你的成績";
cin>>score;
switch(score){
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;
}
cout<<endl;
goto re;
system ("pause");
return 0;
}作者: 陳俞安 時間: 2024-6-8 15:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int score;
re:
cout<<"輸入你的成績"<<endl;
cin>>score;
switch(score){
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;