Try   HackMD

9-1 分數等第

CHAWTeam

目錄:DICE C語言程式破解

題目

寫一個程式讓使用者輸入分數,印出分數等級。
如100到90之間是等級 A,其餘分數與等級關係如下:
89-80 B
79-70 C
69-60 D
59-0 F
請輸出「Your score is (分數) and degree is (等第)!」

因為此題輸出有多種狀況,故需將程式碼複製3次,都判斷正確才給分,每個輸出都要換行。

以下提供 2 種範例參考,你的輸出只會是其中一種:

輸入範例1:
85

輸出範例1:
Your score is 85 and degree is B!

輸入範例2:
60

輸出範例2:
Your score is 60 and degree is D!

範例程式:
#include <stdio.h>
int main(){
int x;
scanf("%d",&x);
if (.....){printf(...);}
else if (.....){printf(...);}
else if (......){printf(...);}
else if (......){printf(...);}
else{printf(...);}
return 0;
}

程式碼

#include <stdio.h> int main() { int x; scanf("%d", &x); if (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); return 0; }

輸出

85
Your score is 85 and degree is B!
60
Your score is 60 and degree is D!
85
Your score is 85 and degree is B!

查看我們在HackMD上的所有筆記
目錄:DICE C語言程式破解


👉【幫我們一個忙!】👈

👋如果您喜歡這篇文章,請在下方按5個Like!
❤您的支持是我們最大的動力!

您只要登入帳號(Facebook、Google),在下方按5個Like,我們就會收到來自LikeCoin基金會的贊助。
您只需要支持我們,完全不會花到錢!