This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

35
TangDou/XiTi/1355.cpp Normal file
View File

@@ -0,0 +1,35 @@
#include <bits/stdc++.h>
using namespace std;
struct Student {
string name;
float score;
};
//对比的方法
/*
用大于号就是从大到小排序,用小于号就是从小到大排序
*/
bool compare(const Student &x, const Student &y) {
return x.score > y.score;
}
int main() {
int n;
cin >> n;
//利用指针动态声明结构体数组
Student *s = new Student[n];
for (int i = 0; i < n; ++i) {
cin >> s[i].score >> s[i].name;
}
//排序
sort(s, s + n, compare);
cout << s[0].name << endl;
//删除指针数组
delete[]s;
return 0;
}