Description
给你一组数(未排序),请你设计一个程序:求出里面个数最多的数。并输出这个数的长度。
例如:给你的数是:1、 2、 3、 3、 4、 4、 5、 5、 5 、6, 其中只有6组数:1, 2, 3-3, 4-4, 5-5-5 and 6.
最长的是5那组,长度为3。所以输出3。
Input
第一行为整数t((1 ≤ t ≤ 10)),表示有n组测试数据。
每组测试数据包括两行,第一行为数组的长度n (1 ≤ n ≤ 10000)。第二行为n个整数,所有整数Mi的范围都是(1 ≤ Mi < 2^32)
Output
对应每组数据,输出个数最多的数的长度。
Sample Input
1101 2 3 3 4 4 5 5 5 6
Sample Output
3
HINT
Source
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[10005],b[10005]={0};
int t,n;
int i,j;
int count=0;
int max;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0; i<n; i++)
{
for(j=i+1; j<n; j++)
{
if(a[i]==a[j])
{
count++;
}
}
b[i]=count;
count=0;
}
max=b[0];
for(i=1; i<n; i++)
{
if(max<b[i])
max=b[i];
}
printf("%d\n",max+1);
}
return 0;
}