#include<iostream>
using namespace std;
typedef struct fun
{
int t,x;
}rr;
int cmp(const void *a,const void *b)
{
fun *c=(fun *)a;
fun *d=(fun *)b;
if(c->t==d->t)//就是个数都相同的
return c->x-d->x;//升序排列的
else
return d->t-c->t;//降序排列的
}
fun a[10005];
int main()
{
int i,j,n,m,s;
while(1)
{
scanf("%d%d",&n,&m);
if(n==0 && m==0)
break;
for(i=0; i<=10000; i++)
{
a[i].t=0;
a[i].x=i;//记录的是原来的坐标的
}
for(i=1; i<=n; i++)
for(j=1; j<=m; j++)
{
cin>>s;
a[s].t++;
}
qsort(a,10001,sizeof(fun),cmp);//升序排列
s=a[1].t;
printf("%d",a[1].x);
i=2;
while(a[i].t==s)
{
printf(" %d",a[i].x);
i++;
}
cout<<endl;
}
return 0;
}
计数排序 poj2092
最新推荐文章于 2019-01-08 02:59:42 发布