1235
統計同成績學生人數
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 21508 Accepted Submission(s): 12163
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
5
60 75 90 55 75
75
Sample Output
1
2
Hint
Hint
Huge input, scanf is recommended.
Source
浙大計算機研究所學生複試上機考試-2006年
Recommend
JGShining | We have carefully selected several similar problems for you: 1230 1229 1237 1236 1233
#include<cstdio>
#include<map>
using namespace std;
int main()
{
int n;
while (scanf("%d",&n),n)
{
map<int, int>a;
int m;
while (n--)
{
scanf("%d", &m);
a[m]++;
}
scanf("%d", &m);
printf("%d\n", a[m]);
}
return ;
}