有關C program正確答案

2007-04-11 12:08 am

回答 (1)

2007-04-11 7:23 pm
✔ 最佳答案
就靠睇唔係好難,但係我唔係好清楚你想d grades係點輸入,我當作個程式入面已經有啦:

#include < stdio.h>

void main() {

int scores [3];
// 請在此自行更換輸入值
scores [0] = 60;
scores [1] = 70;
scores [2] = 80;

int average = ( scores [0] + scores [1] + scores [2] ) / 3;

if (average >= 90) printf("Grade A \n ");
else if (average >= 70) {
if (scores [2] > 90) printf("Grade A \n ");
else printf("Grade B \n ");
} else if (average >= 50) {
if (( scores [1] + scores[2] ) / 2 > 70) printf("Grade C \n ");
else printf("Grade D \n ");
} else printf("Grade F \n ");

}

簡單黎講,呢段程式係咁上下,但係其實可以改善,但係我唔想令你睇落太複雜,所以寫得簡單d,唔修改啦

有咩疑問,歡再問


收錄日期: 2021-04-25 19:52:36
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070410000051KK03205

檢視 Wayback Machine 備份