简单题。
附ac代码:
#include <stdio.h>
#include <stdlib.h>
struct node{
int num, time;
};
int cmp(const void *a, const void *b){
return *(int *)a - *(int *)b;
}
int main(){
node max;
int t, n, i, temp, *a, j;
scanf("%d", &t);
while(t-- && scanf("%d", &n)){
a = (int *)malloc(sizeof(int) * n);
for(i = 0; i != n; ++i)
scanf("%d", &a[i]);
qsort(a, n, sizeof(int), cmp);
for(i = 0, j = 1, max.num = max.time = 0; i != n; ++i)
if(a[i] == a[i + 1]) ++j;
else if(j > max.time)
max.num = a[i], max.time = j, j = 1;
else j = 1;
printf("%d\n", max.num);
free(a);
}
return 0;
}