`
bcyy
  • 浏览: 1809876 次
文章分类
社区版块
存档分类
最新评论

杭电OJ——1235 统计同成绩学生人数

 
阅读更多

统计同成绩学生人数


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.

Source

Recommend
JGShining
水题,没难度!直接发代码:
#include<iostream>
using namespace std;
const int MAX=10000;

int main()
{
	int arr[MAX];
	int num,i,sum,com;
	while(cin>>num && num!=0)
	{
		for(i=0;i<num;i++)
		{
			scanf("%d",&arr[i]);
		}
		cin>>com;
		sum=0;
		for(i=0;i<num;i++)
		{
			if(arr[i]==com)
				sum++;
		}
		cout<<sum<<endl;
	}
	return 0;
}



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics