#28760: _CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59

#include <iostream>
#include <algorithm>
using namespace std;

class student{
public:
int id;
string no;
string name;
};
bool cmp(student i, student j){
if (i.no[8]==j.no[8]){
if (i.no[0]==j.no[0]){
return i.id<j.id;
}
else {
return i.no[0]<j.no[0];
}
}
else {
return i.no[8]<j.no[8];
}
}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
string s;
student a[100];
cin >> n;
for (int i=0; i<n; i++){
cin >> a[i].no >> a[i].name, a[i].id=i;
}
sort(a, a+n, cmp);
for (int i=0; i<n; i++){
cout << a[i].no[8] <<": "<< a[i].name <<endl;
}
}