#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
int n,m,k,i,j;
double num;
struct node
{
int nn;
double c;
}p[1000];
bool cmp1(struct node a,struct node b)
{
return a.c>b.c;
}
bool cmp2(struct node a,struct node b)
{
return a.nn>b.nn;
}
int main()
{
//int
while(scanf("%d%d%d",&n,&m,&k)!=EOF){
// printf("%d %d %d\n",n,m,k);
memset(p,0,sizeof(p));
for(i=0;i<=n-1;i++){
for(j=0;j<=m-1;j++){
scanf("%lf",&num);
p[j].c+=num;
p[j].nn=j+1;
// printf("%d,%d",i,j);
}
}
sort(p,p+m,cmp1);
sort(p,p+k,cmp2);
printf("%d",p[0].nn);
for(i=1;i<=k-1;i++)printf(" %d",p[i].nn);
printf("\n");
}
return 0;
}
先按满意度排序,找出来前k个后再按序号降序排序
这里用了sort函数,真的好方便