Distribution of student achievement

Distribution of student achievement: a student reads N percentile scores, the statistical distribution of a five-point performance. Conversion rule to a five-point score percentile score: not less than 90 is divided into A; less than 90 and greater than or equal to 80 B; 80 less than and greater than or equal to 70 are C; less than 70 and greater than or equal to 60 D; 60 is less than E. In the first line input is given a positive integer N (≤1000), i.e., the number of students; given in the second row of the N th percentile score students, separated by a space therebetween. The number of output A, B, C, D, E corresponding to the five-point distribution results in a row, separated by a space between the numbers, end of line can not have extra space.

#include <stdio.h>

void main() {
    int a, b, c, d, e, n, i, arr[1000] = {0};
    scanf("%d", &n);
    a = b = c = d = e = 0;
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        if (arr[i] >= 90)
            a++;
        else if (arr[i] >= 80)
            b++;
        else if (arr[i] >= 70)
            c++;
        else if (arr[i] >= 60)
            d++;
        else
            e++;
    }
    printf("%d %d %d %d %d", a, b, c, d, e);
}
Published 139 original articles · won praise 4 · Views 930,000 +

Guess you like

Origin blog.csdn.net/qq_38490457/article/details/104808237