B站2022模擬高考成績發(fā)布:I茗清I考了630分

#include <stdio.h>
int main() {
int numStudents, i;
float score, total = 0;
int excellent = 0, good = 0, average = 0, pass = 0, fail = 0;
printf("歡迎使用成績轉(zhuǎn)換程序!\n");
printf("請輸入要轉(zhuǎn)換的人數(shù):");
scanf("%d", &numStudents);
for (i = 1; i <= numStudents; i++) {
printf("請輸入第%d個學(xué)生的成績:", i);
scanf("%f", &score);
total += score;
if (score >= 90) {
excellent++;
} else if (score >= 80) {
good++;
} else if (score >= 70) {
average++;
} else if (score >= 60) {
pass++;
} else {
fail++;
}
}
printf("\n轉(zhuǎn)換結(jié)果如下:\n");
printf("優(yōu):%d人,占比%.2f%%\n", excellent, (float)excellent / numStudents * 100);
printf("良:%d人,占比%.2f%%\n", good, (float)good / numStudents * 100);
printf("中:%d人,占比%.2f%%\n", average, (float)average / numStudents * 100);
printf("及格:%d人,占比%.2f%%\n", pass, (float)pass / numStudents * 100);
printf("不及格:%d人,占比%.2f%%\n", fail, (float)fail / numStudents * 100);
return 0;
}