#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
using std::cin;
#include <list>
using std::list;
#include <vector>
using std::vector;
#include <string>
using std::string;
#include <algorithm>
using std::sort;
using std::for_each;
#include "Person14.h"
#include "Date14.h"
static Date silvester(31, 12);
bool getrecord(string& nbuf, string& fbuf, int& y, int& m, int& d)
{
char sep;
return (cin >> nbuf >> fbuf >> y >> sep >> m >> sep >> d);
}
bool PersFirstLess(const Person *lhs, const Person *rhs) {
return (lhs->firstName() <= rhs->firstName());
}
struct PersNameLess {
bool operator()(const Person *lhs, const Person *rhs) {
return (lhs->lastName() <= rhs->lastName());
}
};
struct ProcessPers {
void operator()(const Person *p) {
cout << p->lastName() << ' ' << p->firstName() << ' ' <<
p->birthday() << ", Alter: " << silvester - p->birthday() <<
" Tage" << endl;
delete p;
}
};
int main() {
string nbuf;
string fbuf;
int y, m, d;
list<Person*> plist;
vector<Person*> pvector;
while ( getrecord(nbuf, fbuf, y, m, d) ) {
plist.push_back(new Person(nbuf, fbuf, d, m, y));
pvector.push_back(new Person(nbuf, fbuf, d, m, y));
}
plist.sort(PersNameLess());
for_each(plist.begin(), plist.end(), ProcessPers());
sort(pvector.begin(), pvector.end(), PersFirstLess);
for_each(pvector.begin(), pvector.end(), ProcessPers());
return 0;
}