有没有小伙伴帮我看看?
题目要求输入:第一行包含一个整数n表示学生人数(1≤n≤10000)。接下来的一行中有n个代表学生分数的介于[0,100] 整数;
输出:按照以下示例的输出格式,依次输出每个分数值上的人数。
0 score:1
1 score:0
2 score:0
3 score:0
4 score:0
5 score:0
6 score:0
7 score:0
8 score:0
9 score:0
10 score:0
一直到100 score:0
#include <stdio.h>
int main() {
int grades[11] = { 0 };
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int num;
scanf("%d", &num);
grades[num / 10]++;
}
for (int i = 0; i < 11; i++) {
printf("%d score:%d", i, grades[i]);
}
}