Solution
#include <stdio.h>
int main(){
int n,i,s,j;
scanf("%d", &n);
for(i=0;i<n;i++)
{
scanf("%d",&s);
int a[s],b[1000000],max=0;
for(j=0;j<s;j++)
{
scanf("%d",&a[j]);
}
for(j=0;j<1000000;j++)
{
b[j] = 0;
}
for(j=0;j<s;j++)
{
if(b[a[j]] == 0)
{
b[a[j]] = 1;
}
else
{
b[a[j]] = b[a[j]] + 1;
}
}
for(j=0;j<1000000;j++)
{
if(b[j] >= max)
{
max = b[j];
}
}
for(j=1000000;j>0;j--)
{
if(b[j] == max)
{
printf("%d ",j);
}
}
}
return 0;
}
No comments:
Post a Comment