#include<cstdio>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
struct email{
string username,domain;
}ary[1000000];
bool cmp(email a,email b){
if(a.domain!=b.domain) return a.domain<b.domain;
else return a.username>b.username;
}
int main(){
int n;
scanf("%d",&n);
getchar();
for(int i=0;i<n;i++){
string tem;
int j,len=tem.length();
getline(cin,tem);
for(j=0;j<tem.length();j++){
if(tem[j]=='@') break;
}
ary[i].username=tem.substr(0,j);
ary[i].domain=tem.substr(j+1,tem.length()-1-j);
}
sort(ary,ary+n,cmp);
for(int i=0;i<n;i++){
cout<<ary[i].username<<'@'<<ary[i].domain<<endl;
}
return 0;
}
2019级程设模拟机考 B. 邮件地址排序
最新推荐文章于 2024-04-24 08:04:45 发布