浅浅装个B
2024-05-13 23:38:32
发布于:广东
2阅读
0回复
0点赞
不想用cmp
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
struct node{
string name;
int atk, price;
bool operator < (const node &b) const{
if(atk == b.atk){
return price < b.price;
}return atk > b.atk;
}
}a[105];
int main(){
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i].name >> a[i].atk >> a[i].price;
}sort(a + 1, a + n + 1);
for(int i = 1; i <= m; i++) cout << a[i].name << endl;
return 0;
}
这里空空如也
有帮助,赞一个