小郭冲冲冲 @ 2024-03-17 11:53:09
using namespace std;
int n;
vector<pair<string,int>> mp;
int re(string s){
int x = 0;
for(auto tt:s){
x *= 10;
x += tt - '0';
}
return x;
}
typedef struct{
string s;
int num;
}stu;
bool cmp(stu mp1,stu mp2){
return mp1.num < mp2.num;
}
int main(){
stu stu1[1010];
cin >> n;
for(int i = 1;i <= n;i++){
string s1,s2,s3,s4;
cin >> s1 >> s2 >> s3 >> s4;
stu1[i].s = s1;
stu1[i].num = re(s3)*100+re(s4)+re(s2)*10000;
}
sort(stu1+1,stu1+1+n,cmp);
for(int i = 1;i <= n;i++){
cout << stu1[i].s<<endl;
}
}
by Ew_Cors @ 2024-03-17 11:59:08
你 stable 啥了。
by AAAuc03 @ 2024-03-17 12:53:36
没必要这么麻烦,直接结构体数组排序就行了,把姓名,年月日一起放结构体再按要求排序就行了呀,然后输出姓名就完事了