题目链接
水题,,注意初始化为-1,一开始初始化为0,坑了自己好几把。
代码如下:
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;typedef long long ll;const int N = 1e5+10;int n, m, maxn, tmp;ll a, cnt;int sum[200];int main(){scanf("%d%d", &n, &m);memset(sum, 0, sizeof(sum));for(int i = 1; i <= m; i++){cnt = -1;for(int j = 1; j <= n; j++){scanf("%I64d", &a);if(cnt < a){cnt = a;tmp = j;}}sum[tmp]++;}maxn = -1, tmp = 0;for(int j = 1; j <= n; j++){if(maxn < sum[j]){maxn = sum[j];tmp = j;}}printf("%d\n", tmp);return 0;}
版权声明:本文为博主原创文章,未经博主允许不得转载。
己欲立先立人,已欲达先达人。