123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- // Твой исходный файл
- #include <iostream>
- #include <string>
- #include <windows.h>
- using namespace std;
- struct Student
- {
- int mark;
- string name;
- };
- struct School
- {
- int number;
- };
- struct Score
- {
- double score;
- };
- class Journal
- {
- private:
- Student* students;
- School* schools;
- Score* scores;
- int NumberOfStudents = 0;
- int NOS = 0;
- int KolS = 0;
- int StudentData = 0;
- int AverageScore = 0;
- public:
- void NumOfSchool(int nos, int num)
- {
- NOS = nos;
- schools = new School[NOS];
- schools[KolS].number = num;
- KolS++;
- }
- void NumberOfStds(int kol)
- {
- NumberOfStudents = kol;
- students = new Student[NumberOfStudents];
- }
- void SetStds(string name, int mark)
- {
- students[StudentData].name = name;
- students[StudentData].mark = mark;
- StudentData++;
- }
- void SaR(double as)
- {
- scores = new Score[NOS];
- scores[AverageScore].score = as;
- }
- string Spisok()
- {
- string b;
- for (int i = 0; i < KolS; i++) {
- b = b + "Школа №: " + to_string(schools[i].number) + "\n";
- }
- return b;
- }
- string SpisokSt()
- {
- string sp;
- for (int i = 0; i < NumberOfStudents; i++) {
- sp = sp + " Фамилия: " + students[i].name + " Оценка: " + to_string(students[i].mark)+"\n";
- }
- return sp;
- }
- string AverScore()
- {
- string h;
- for (int i = 0; i < KolS; i++) {
- h = h + " Средний балл: " + to_string(scores[i].score)+"\n";
- }
- return h;
- }
- void Idol()
- {
- cout << "Фамилия ученика с баллом выше среднего: "<<"\n";
- string u;
- for (int i = 0; i < KolS; i++) {
- for (int j = 0; j < NumberOfStudents; j++) {
- if (scores[i].score < students[j].mark) {
- u = u +" | "+students[j].name+" | "+"\n";
- }
- }
- cout << u << "\n";
- }
- }
- };
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- setlocale(LC_ALL, "rus");
- int kolschool;
- int kolstudents;
- int numofschool;
- string familia;
- int mark;
- double averagescore = 0;
- cout << "Введите количество школ: ";
- cin >> kolschool;
- Journal* journals = new Journal[kolschool];
- for (int i = 0; i < kolschool; i++) {
- cout << "\nВведите номер школы: ";
- cin >> numofschool;
- journals[i].NumOfSchool(kolschool,numofschool);
- cout << "Введите количество учеников: ";
- cin >> kolstudents;
- journals[i].NumberOfStds(kolstudents);
- for (int j = 0; j < kolstudents; j++) {
- cout << "\nВведите фамилию для " << j + 1 << " ученика : ";
- cin >> familia;
- cout << "Введите оценку для " << j + 1 << " ученика : ";
- cin >> mark;
- journals[i].SetStds(familia, mark);
- averagescore += mark;
- }
- averagescore = averagescore / kolstudents;
- journals[i].SaR(averagescore);
- averagescore = 0;
- }
- for (int i = 0; i < kolschool; i++) {
- cout << "\n" << journals[i].Spisok();
- cout << "\n" << journals[i].SpisokSt();
- cout << "\n" << journals[i].AverScore();
- journals[i].Idol();
- }
- }
|