连接
http://codeup.cn/problem.php?cid=100000576&pid=0
题目描述
读入N名学生的成绩,将获得某一给定分数的学生人数输出。
输入
测试输入包含若干测试用例,每个测试用例的格式为
第1行:N
第2行:N名学生的成绩,相邻两数字用一个空格间隔。
第3行:给定分数
当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。
输出
对每个测试用例,将获得给定分数的学生人数输出。
样例输入 Copy
4
70 80 90 100
80
3
65 75 85
55
5
60 90 90 90 85
90
0
样例输出 Copy
1
0
3
#include<stdio.h>
#define N 1010
//当n=0,时结束,读题读清楚!!!!!!!!!!!!!!!!!
//循环里面还需要有一个输入
int main() {
int population;
scanf("%d",&population);
while(population){
int pupillaryscore[N];
for(int i=0;i<population;i++){
scanf("%d",&pupillaryscore[i]);
}
int givenscore,number=0;
scanf("%d",&givenscore);
for(int i=0;i<population;i++){
if(pupillaryscore[i]==givenscore) number++;
}
printf("%d\n",number);
scanf("%d",&population);
}
return 0;
}