11.3 作业 Problem L: 数字统计

来源:互联网 发布:家庭网络如何共享文件 编辑:程序博客网 时间:2024/06/16 12:56

Description

给出一些数字,统计出现最多的数字的次数。

Input

输入中第一行包含一个N,0 < N <= 500000。

后面N行每行包含一个数字k,0<=k<=200000。

Output

输出出现次数最多的数字的个数。

Sample Input

5
1
1
2
3
4

Sample Output

2


思路:

相当流氓的做法。开一个数组。因为只有0-9会输入。输入一个数n  相应的下标对应的a[n]++。然后判断最大值。

一层循环即可完成。


代码:

#include<stdio.h>int main(){    int i,N,max=0,s,b[200001];    scanf("%d",&N);    for (i=0;i<N;i++)    {        scanf("%d",&s);        b[s]++;        if(b[s]>max)        max=b[s];    }    printf("%d\n",max);}




0 0
原创粉丝点击