给定一个百分位数分数T,将其划分为以下五级之一: 90~100为A,80~89为B,70~79为c,60~69为ISD,0~59为EE。 有几个百分位数的分数(分数不超过1000),请数数这五个级别中的人数,找出人数最多的级别,并按降序输出每个人的分数(只有一个级别,人数最多)。用c语言编写程序
时间: 2023-07-15 10:11:14 浏览: 163
以下是一个简单的C语言程序来实现这个任务:
```c
#include <stdio.h>
int main() {
int n, score, count_A = 0, count_B = 0, count_C = 0, count_D = 0, count_E = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &score);
if (score >= 90 && score <= 100) {
count_A++;
} else if (score >= 80 && score <= 89) {
count_B++;
} else if (score >= 70 && score <= 79) {
count_C++;
} else if (score >= 60 && score <= 69) {
count_D++;
} else {
count_E++;
}
}
int max_count = count_A, max_score = 0;
if (count_B > max_count) {
max_count = count_B;
max_score = 80;
}
if (count_C > max_count) {
max_count = count_C;
max_score = 70;
}
if (count_D > max_count) {
max_count = count_D;
max_score = 60;
}
if (count_E > max_count) {
max_count = count_E;
max_score = 0;
}
printf("%d\n", max_count);
if (max_score == 0) {
for (int i = 0; i < n; i++) {
if (score >= 0 && score <= 59) {
printf("%d ", score);
}
}
} else if (max_score == 60) {
for (int i = 0; i < n; i++) {
if (score >= 60 && score <= 69) {
printf("%d ", score);
}
}
} else if (max_score == 70) {
for (int i = 0; i < n; i++) {
if (score >= 70 && score <= 79) {
printf("%d ", score);
}
}
} else if (max_score == 80) {
for (int i = 0; i < n; i++) {
if (score >= 80 && score <= 89) {
printf("%d ", score);
}
}
} else {
for (int i = 0; i < n; i++) {
if (score >= 90 && score <= 100) {
printf("%d ", score);
}
}
}
return 0;
}
```
输入格式:第一行输入整数n,表示分数数量。接下来n行,每行输入一个整数表示分数。
输出格式:第一行输出人数最多的级别中的人数。接下来输出每个人的分数(只有一个级别,人数最多),按降序输出。
阅读全文