题解 | #统计同成绩学生人数#

统计同成绩学生人数

https://www.nowcoder.com/practice/987123efea5f43709f31ad79a318ca69

#include <stdio.h>
int main(){
    int N;
    while(scanf("%d", &N) != EOF){
        if(N == 0){
            break;
        }
        int grade[1001] = {0};
        for (int i = 0; i < N; ++i) {
            scanf("%d", &grade[i]);
        }
        int score = 0;
        int count = 0;
        scanf("%d", &score);
        //判断并输出
        for (int i = 0; i < N; ++i) {
            if (grade[i] == score){
                count++;
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

全部评论

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务