Skip to content

Instantly share code, notes, and snippets.

@goodjack
Last active November 4, 2017 12:43
Show Gist options
  • Save goodjack/785a019566ef5492a418f6c64fa9da15 to your computer and use it in GitHub Desktop.
Save goodjack/785a019566ef5492a418f6c64fa9da15 to your computer and use it in GitHub Desktop.
While 迴圈之成績判斷參考解答
#include <iostream>
using namespace std;
int main()
{
int score;
cout << "==========================================\n";
cout << "成績判定,輸入範圍 0 ~ 100,超過範圍就掰掰\n";
cout << "==========================================\n";
while (true) {
cout << "請輸入成績:";
cin >> score;
if (score > 100 || score < 0) {
break;
} else if (score >= 90) {
cout << "分析結果:高分,你好厲害\n";
} else if (score > 60) {
cout << "分析結果:及格,勉強接受啦\n";
} else if (score == 60) {
cout << "分析結果:剛好及格,驚險過關\n";
} else {
cout << "分析結果:不及格,加油好嗎\n";
}
}
cout << "程式結束,掰掰!";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment