hdu 1234 开门人关门人

 问题不难,关键是看看自己处理字符串的能力了

#include<iostream>
#include<algorithm>
#include<string>
//#include<fstream>
using namespace std;

struct peo{
string name;
string first;
string last;
};

int bmp(peo a,peo b){
return a.first < b.first;
}
int bmp2(peo a,peo b){
return a.last > b.last;
}

peo str[500];
int main()
{
//ifstream cin("in.txt");
int T,N;
while(cin>>N)
{
for(int i=1;i<=N;i++)
{
int T;
cin>>T;
for(int i=0;i<T;i++)
{
cin>>str[i].name>>str[i].first>>str[i].last;
}
sort(str,str+T,bmp);
cout<<str[0].name<<" ";
sort(str,str+T,bmp2);
cout<<str[0].name<<endl;

}
}
}

原文地址:https://www.cnblogs.com/lfyy/p/2800157.html