- //if...else if...else
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- int score;
- cout<<"請輸入你的成績: ";
- cin>>score;
- if(score==100)
- cout<<"哇!滿分!"<<endl;
- else if(score<100 && score>=60)
- cout<<"恭喜你及格了,給你糖吃!"<<endl;
- else if(score>0 && score<60)
- cout<<"不及格!"<<endl;
- else if(score==0)
- cout<<"零分?"<<endl;
- else
- cout<<"輸入錯誤!"<<endl;
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |