#include <iostream>
#include <string>
using namespace std;
class Footballer {
private:
string surname;
string role;
int age;
int games;
int goals;
public:
void input() {
cout << "Введите фамилию: ";
cin >> surname;
cout << "Введите амплуа: ";
cin >> role;
cout << "Введите возраст: ";
cin >> age;
cout << "Введите количество игр: ";
cin >> games;
cout << "Введите количество голов: ";
cin >> goals;
}
void display() const {
cout << "Фамилия: " << surname << "\t";
cout << "Амплуа: " << role << "\t";
cout << "Возраст: " << age << "\t";
cout << "Игр: " << games << "\t";
cout << "Голов: " << goals << endl;
}
string getRole() const { return role; }
int getGoals() const { return goals; }
int getGames() const { return games; }
};
int main() {
setlocale(LC_ALL, "Russian");
int n;
cout << "Введите количество футболистов: ";
cin >> n;
Footballer* team = new Footballer[n];
// Ввод данных
for (int i = 0; i < n; i++) {
cout << "\nДанные для игрока " << (i + 1) << ":" << endl;
team[i].input();
}
// Поиск лучшего форварда
int maxGoals = -1;
int bestForwardIndex = -1;
for (int i = 0; i < n; i++) {
if (team[i].getRole() == "форвард" && team[i].getGoals() > maxGoals) {
maxGoals = team[i].getGoals();
bestForwardIndex = i;
}
}
if (bestForwardIndex != -1) {
cout << "\nЛучший форвард:" << endl;
team[bestForwardIndex].display();
} else {
cout << "\nВ команде нет форвардов." << endl;
}
// Вывод игроков с менее 5 играми
cout << "\nИгроки, сыгравшие менее 5 игр:" << endl;
bool found = false;
for (int i = 0; i < n; i++) {
if (team[i].getGames() < 5) {
team[i].display();
found = true;
}
}
if (!found) {
cout << "Таких игроков нет." << endl;
}
delete[] team;
return 0;
}