zoey
点击国内主页可以让浏览速度加快哦 ~ !

关于HDOJ 1235题(统计同成绩学生人数) 的理解(C/C++)

2019-08-12 hdoj 统计 浙大计算机研究生复试上机考试-2006年
Word count: 325 | Reading time: 1min

    水题




题目描述:统计同成绩学生人数

统计同成绩学生人数
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/32768 K (Java/Others)

Problem Description
    读入N名学生的成绩,将获得某一给定分数的学生人数输出。

Input
    测试输入包含若干测试用例,每个测试用例的格式为

第1行:N
第2行:N名学生的成绩,相邻两数字用一个空格间隔。
第3行:给定分数

当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。

Output
    对每个测试用例,将获得给定分数的学生人数输出。

Sample Input
3
80 60 90
60
2
85 66
0
5
60 75 90 55 75
75
0

Sample Output
1
0
2

Hint
Hint

Huge input, scanf is recommended.

Author
    Ignatius.L

Source
    浙大计算机研究生复试上机考试-2006年

原题链接

More info:Question

Accepted代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>

using namespace std;

const int maxn = 1001;
int n, grade[maxn],tar,res;
int main()
{
while (cin >> n) {
if (n == 0) break;
res = 0;
for (int i = 0; i < n; i++) cin >> grade[i];
cin >> tar;
for (int i = 0; i < n; i++) {
if (tar == grade[i]) res++;
}
cout << res << endl;
}
return 0;
}

参考博客

Author: Zoey

Link: https://zoey1038569979.github.io/2019/08/12/hdoj1235/

Copyright: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.

< PreviousPost
关于HDOJ 1236题(排名) 的理解(C/C++)
NextPost >
关于HDOJ 1234题(开门人和关门人) 的理解(C/C++)
CATALOG
  1. 1. 题目描述:统计同成绩学生人数
  2. 2. 原题链接
  3. 3. Accepted代码
  4. 4. 参考博客