--- tags: DICE C --- 11-1 分數等第 === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- 題目 --- ```! 試一試其他的方法,來解題: 寫一個程式讓使用者輸入分數,印出分數與等級。 分數與等級的換算如下: 100-90 A 89-80 B 79-70 C 69-60 D 59-0 F 因為此題輸出有多種狀況,故需將程式碼複製3次,都判斷正確才給分,每個輸出都要換行。 輸入範例1: 85 輸出範例1: Your score is 85 and degree is B! 輸入範例2: 63 輸出範例2: Your score is 63 and degree is D! C範例程式: f(x>=90) printf("Your score is %d and degree is A!\n",x); else if(x>=80) printf("Your score is %d and degree is B!\n",x); else if (x>=70)printf("Your score is %d and degree is C!\n",x); else if (x>=60)printf("Your score is %d and degree is D!\n",x); else printf("Your score is %d and degree is F!\n",x); C++範例程式: cin>>x; if (x>=90) cout<<"Your score is "<<x<<" and degree is A!"<<endl; else if (x>=80) cout<<"Your score is "<<x<<" and degree is B!"<<endl; else if (x>=70) cout<<"Your score is "<<x<<" and degree is C!"<<endl; else if (x>=60) cout<<"Your score is "<<x<<" and degree is D!"<<endl; else cout<<"Your score is "<<x<<" and degree is F!"<<endl; ``` 程式碼 --- ```c= #include <stdio.h> int main() { int x; scanf("%d", &x); if (x >= 90 && x <= 100) printf("Your score is %d and degree is A!\n", x); else if (x >= 80 && x < 90) printf("Your score is %d and degree is B!\n", x); else if (x >= 70 && x < 79) printf("Your score is %d and degree is C!\n", x); else if (x >= 60 && x < 69) printf("Your score is %d and degree is D!\n", x); else printf("Your score is %d and degree is F!\n", x); scanf("%d", &x); if (x >= 90 && x <= 100) printf("Your score is %d and degree is A!\n", x); else if (x >= 80 && x < 90) printf("Your score is %d and degree is B!\n", x); else if (x >= 70 && x < 79) printf("Your score is %d and degree is C!\n", x); else if (x >= 60 && x < 69) printf("Your score is %d and degree is D!\n", x); else printf("Your score is %d and degree is F!\n", x); scanf("%d", &x); if (x >= 90 && x <= 100) printf("Your score is %d and degree is A!\n", x); else if (x >= 80 && x < 90) printf("Your score is %d and degree is B!\n", x); else if (x >= 70 && x < 79) printf("Your score is %d and degree is C!\n", x); else if (x >= 60 && x < 69) printf("Your score is %d and degree is D!\n", x); else printf("Your score is %d and degree is F!\n", x); return 0; } ``` 執行 --- ```! 85 Your score is 85 and degree is B! 63 Your score is 63 and degree is D! 72 Your score is 72 and degree is C! ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-11-1" width="100%"></iframe> --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}