教你用最放心的方法解
2024-09-07 14:52:28
发布于:云南
4阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct node{
string name;
int id,score;
}a[105];
bool cmp(node a,node b){return a.id < b.id;}
int main(){
int n; cin >> n;
for(int i = 1;i <= n;i++){
string t; cin >> t >> a[i].name >> a[i].score;
a[i].id = stoi(t);
}
sort(a + 1,a + n + 1,cmp);
for(int i = 1;i <= n;i++) cout << a[i].score << "\n";
return 0;
}
全部评论 1
为什么要用stoi呢?我也不知道
2024-09-15 来自 云南
0
有帮助,赞一个