-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_dynamical.cpp
More file actions
40 lines (33 loc) · 1.11 KB
/
Copy pathstudent_dynamical.cpp
File metadata and controls
40 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <string>
using namespace std;
struct Student {
string name;
int age;
float average;
};
int main() {
int n;
cout << "Введите количество студентов для записи: ";
cin >> n;
cout << endl;
Student* students = new Student[n];
for (int i = 0; i < n; i++) {
cout << "Введите имя: ";
cin >> students[i].name;
cout << "Введите возраст: ";
cin >> students[i].age;
cout << "Введите рейтинг: ";
cin >> students[i].average;
cout << endl << endl;
}
int best = 0, worst = 0;
for (int i = 0; i < n; i++) {
if (students[i].average > students[best].average) best = i;
if (students[i].average < students[worst].average) worst = i;
}
cout << "Лучший студент: " << students[best].name << " Рейтинг: " << students[best].average << endl;
cout << "Худший студент: " << students[worst].name << " Рейтинг: " << students[worst].average << endl;
delete[] students;
return 0;
}