hdu 5123 who is the best?(水)

来源:互联网 发布:夏亚大魔数据 编辑:程序博客网 时间:2024/05/17 00:59

题目连接:hdu 5123 who is the best?


#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int maxn = 105;int main () {int cas, n, x, c[maxn];scanf("%d", &cas);while (cas--) {scanf("%d", &n);memset(c, 0, sizeof(c));for (int i = 0; i < n; i++) {scanf("%d", &x);c[x]++;}int ans = c[1], idx = 1;for (int i = 2; i <= n; i++) {if (c[i] > ans) {ans = c[i];idx = i;}}printf("%d\n", idx);}return 0;}


0 0
原创粉丝点击