题解 | #牛牛的书#
牛牛的书
https://www.nowcoder.com/practice/30bb969e117b4f6d934d4b60a2af7489
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool cmp(pair<string, int> b1,pair<string, int> b2){
return b1.second<b2.second;
}
int main(){
vector<pair<string, int>> book;
int n;
cin>>n;
for(int i=0;i<n;i++){
string str;
int temp;
cin>>str>>temp;
book.emplace_back(str,temp);
}
sort(book.begin(),book.end(),cmp);
for(auto it=book.begin();it!=book.end();it++)
cout<<it->first<<endl;
}
#include<vector>
#include<algorithm>
using namespace std;
bool cmp(pair<string, int> b1,pair<string, int> b2){
return b1.second<b2.second;
}
int main(){
vector<pair<string, int>> book;
int n;
cin>>n;
for(int i=0;i<n;i++){
string str;
int temp;
cin>>str>>temp;
book.emplace_back(str,temp);
}
sort(book.begin(),book.end(),cmp);
for(auto it=book.begin();it!=book.end();it++)
cout<<it->first<<endl;
}