- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
-
- //宣告變數
- //變數型態 變數名稱(=賦予值)
- int score;
- cout<<"請輸入成績:";
- cin>>score;
-
- //開始判斷
- //分數=100
- if(score==100){
- cout<<"滿分"<<endl;
- }
- //60~99 -> 60<=score<100
- else if(score>=60 && score<100){
- cout<<"好高分"<<score<<endl;
- }
- //1~59 -> 0<=score<60
- else if(score>=1 && score<60){
- cout<<"不及格,你的分數:"<<score<<endl;
- }
- //score=0
- else if(score==0){
- cout<<"零分"<<endl;
- }
- //其他狀況 0~100以外
- else{
- cout<<"輸入錯誤"<<endl;
- }
-
- system("pause"); //黑色畫面暫停
- return 0; //告知主程式已完成
- }
複製代碼 |