Description
输入一些整数,表示学生的考试分数,在0~100之内为合法数据,进行统计。统计出哪个分数出现的次数最多,并按照分数大小从小到大输出。
Input
输入多行,每行一个整数。输入的成绩总数不超过在1~10000个之间。到EOF结束。
Output
输出出现次数最多的那些分数,按从小到大顺序输出。
Sample Input
-1
81
-1
92
35
68
72
100
1000
95
60
59
72
92
Sample Output
72
92
代码如下:
#include<stdio.h>
int main()
{
int n;
int a[101] = {0};
while(scanf("%d",&n)!=EOF)
{
if(n>=0&&n<=100)
{
a[n]++;
}
}
int max = a[0];
for(int i=0;i<101;i++)
{
if(a[i]>max)
{
max = a[i];
}
}
for(int i=0;i<101;i++)
{
if(a[i]==max)
{
printf("%d\n",i);
}
}
return 0;
}