思路:水题,就是注意是每个输出间空一格,不是每个后面跟一个空
代码如下:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int a[11000];
int n, m;
int i,j;
int xb;
int max;
int b[11000];
int x;
while (cin >> n >> m && n && m)
{
memset(a, 0, sizeof(a));
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
cin >> xb;
a[xb]++;
}
}
max = a[0];
for (i = 0; i < 11000; i++)
{
if (a[i]>max)
{
max = a[i];
}
}
for (i = 0; i < 11000; i++)
{
if (a[i] == max)
a[i] = 0;
}
max = a[0];
for (i = 0; i < 11000; i++)
{
if (a[i]>max)
{
max = a[i];
}
}
x = 0;
for (i = 0; i < 11000; i++)
{
if (a[i] == max)
{
b[x++] = i;
}
}
sort(b, b + x);
for (i = 0; i < x; i++)
{
if (i == 0)
printf("%d", b[i]);
else
printf(" %d", b[i]);
}
printf("\n");
}
system("pause");
return 0;
}