1235 统计同成绩学生人数

统计同成绩学生人数

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10872    Accepted Submission(s): 6467


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
 
简单题,看完这题刚开始的想法很简单,后来看到Hint,简化了一下代码!
View Code
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 int main(int argc, char *argv[])
 5 {
 6     int n, temp, a[1005] = {0}, i;
 7     while( (scanf( "%d", &n )!=EOF)&&n )
 8     {
 9            memset(a,0,1005*sizeof(int));
10            for( i = 0; i < n; i++ )
11            {
12                 scanf( "%d", &temp );
13                 a[temp]++;
14            }
15            scanf( "%d", &temp );
16            printf( "%d\n",a[temp] );
17     }
18   
19   //system("PAUSE");    
20   return 0;
21 }

 

 
posted @ 2013-05-03 18:33  翼展zjz  阅读(123)  评论(0编辑  收藏  举报