PAT 人口普查1028c++
#include<iostream>
#include<string>
#include<list>
typedef struct Poll
{std::string name,born;}Poll;
bool compar(Poll A,Poll B)
{return A.born<B.born;}
int main()
{
const std::string standr="2014/09/06",
oldest="1814/09/06";
Poll poll,old,young;
int number(0); std::cin>>number; std::list<Poll> lst(number); while(number--) std::cin>>poll.name>>poll.born,lst.push_back(poll);
lst.sort(compar); std::list<Poll>::iterator ___it=lst.begin(); while(___it!=lst.end())
if(___it->born<oldest||___it->born>standr) ___it=lst.erase(___it);
else ___it++;
if(lst.size()==0) {std::cout<<'0';return 0;} old=lst.front(),young=lst.back(); std::cout<<lst.size()<<' '<<old.name<<' '<<young.name;}在这里插入代码片