C/C++

Не могу справиться с дз по программированию

Помогите решить 1-ую или 2-ую задачу ( в идеале конечно обе)
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <limits>
using namespace std;
void flush(istream& inp = cin) {
inp.ignore(numeric_limits<streamsize>::max(), '\n');
}
struct Student {
short year;
short physics;
short mathematics;
short informatics;
short chemistry;
string group;
string name;
Student() : year(0), physics(0), mathematics(0), informatics(0), chemistry(0) {}
double average()const {
return sum() / 4.0;
}
bool excellent()const {
static const auto min = 7;
return physics > min && mathematics > min && informatics > min && chemistry > min;
}
private:
double sum()const {
return physics + mathematics + informatics + chemistry;
}
short score(istream& inp, const string& msg) {
short value;
do {
cout << msg;
inp >> value;
flush();
} while (value < 0 || value > 10);
return value;
}
friend bool operator<(const Student& a, const Student& b) {
return a.name < b.name;
}
friend ostream& operator<<(ostream& out, const Student& s) {
out << s.name << ' ' << s.year << " г. р., группа: " << s.group << "\n\t"
<< "Физика: " << s.physics << "\n\t"
<< "Математика: " << s.mathematics << "\n\t"
<< "Информатика: " << s.informatics << "\n\t"
<< "Химия: " << s.chemistry << "\n\t"
<< "Средний балл: " << fixed << setprecision(2) << s.average();
return out;
}
friend istream& operator>>(istream& inp, Student& s) {
cout << "Ф. И. О.: ";
getline(inp, s.name);
cout << "Год рождения: ";
inp >> s.year;
flush();
cout << "Номер группы: ";
inp >> s.group;
flush();
s.physics = s.score(inp, "Физика: ");
s.mathematics = s.score(inp, "Математика: ");
s.informatics = s.score(inp, "Информатика: ");
s.chemistry = s.score(inp, "Химия: ");
return inp;
}
};
int main() {
system("chcp 1251 > nul");
cout << "Размер списка: ";
size_t length;
cin >> length;
flush();
auto list = new Student[length];
for (auto i = 0U; i < length; ++i) cin >> list[i];
sort(list, list + length);
for (auto i = 0U; i < length; ++i) {
if (list[i].excellent()) cout << list[i] << '\n';
}
delete[] list;
system("pause > nul");
}
Z-Import.ru Запчасть-Импорт
85 249
Лучший ответ