#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
constexpr auto current = 2021;
struct Person {
char sex;
short birthday;
short year;
string name;
Person()
: sex('-'), birthday(0), year(0), name("-") {}
Person(const char s, const short b, const short y, const string& n)
: sex(s), birthday(b), year(y), name(n) {}
bool older(int age)const {
return current - birthday > age;
}
bool experience(int value)const {
return current - year > value;
}
private:
friend bool operator<(const Person& a, const Person& b) {
return a.name < b.name;
}
friend ostream& operator<<(ostream& out, const Person& p) {
return out
<< left << setw(15) << p.name
<< right << setw(4) << p.sex
<< setw(8) << p.birthday
<< setw(8) << p.year;
}
};
int main() {
system("chcp 1251 > nul");
vector<Person> table{
{ 'М', 1940, 1957, "Анисимов И. О." },
{ 'М', 1980, 1999, "Иванов И. Н." },
{ 'Ж', 1960, 1980, "Махова О. И." },
{ 'М', 1971, 1990, "Огарев К. М." },
{ 'Ж', 1993, 2011, "Егорова П. К." },
{ 'Ж', 1972, 1990, "Голикова О. И." },
{ 'М', 1943, 1960, "Сотников Т. С." },
{ 'М', 1979, 2005, "Комов В. И." },
{ 'М', 1959, 1981, "Лебедев А. А." },
{ 'Ж', 1991, 2010, "Димова В. В." }
};
int n = 0;
for (const auto& record : table) {
cout << setw(3) << ++n << ". " << record << '\n';
}
puts("");
auto comp = [](const Person& a, const Person& b) { return a.birthday > b.birthday; };
sort(table.begin(), table.end(), comp);
n = 0;
for (const auto& record : table) {
if (record.experience(25)) {
cout << setw(3) << ++n << ". " << record << '\n';
}
}
system("pause > nul");
}