版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/QingCoffe/article/details/84106152
这题没啥好说的....没啥感悟,就是排序....
已AC
# include<iostream>
# include<algorithm>
using namespace std;
struct x {
double v;
double index;
}a[1000];
bool cmp(x&a, x&b) {
return a.v > b.v;
}
bool cmp_(x&a, x&b) {
return a.index > b.index;
}
int main(void) {
int N, M, K;//N 人 M元素 K采纳
int i, j;
double num;
while (cin >> N >> M >> K) {
for (i = 0; i < N; i++) {
for (j = 0; j < M; j++) {
cin >> num;
if (!i) {
a[j].v = num;
a[j].index = j;
}
else
a[j].v += num;
}
}
sort(a, a + M, cmp);//大于排序
sort(a, a + K, cmp_);
cout << a[0].index + 1;
for (j = 1; j < K; j++) {
cout << " " << a[j].index+1;
}
cout << endl;
}
system("pause");
return 0;
}