Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h> // SetConsoleCP, SetConsoleOutputCP
- #include <locale.h>
- #include <conio.h>
- #include <algorithm>
- #include <array>
- using namespace std;
- #define і i
- class Student {
- private:
- array<int, 3> score;
- int numberScorebook;
- string lastName;
- public:
- Student(){}
- Student(string lastName, int numberScorebook, array<int, 3> score) {
- this->lastName = lastName;
- this->numberScorebook = numberScorebook;
- this->score = score;
- }
- void AddItemArray(Student* students, int size, int scoreSize)
- {
- array<int, 3> myarray1 = { 8, 6, 4 };
- array<int, 3> myarray2 = { 2, 1, 4 };
- students[0] = Student("q", 1, myarray1);
- students[1] = Student("w", 2, myarray2);
- //int* score = new int[scoreSize];
- //int numberScorebook;
- //string lastName;
- //int j = 0;
- //for (int i = 0; i < size; i++)
- //{
- // cout << "Прізвище: ";
- // cin >> lastName;
- // cout << "Номер залікової книжки: ";
- // cin >> numberScorebook;
- // cout << "Оцінки: ";
- // for (j = 0; j < scoreSize; j++)
- // {
- // cin >> score[j];
- // }
- // j = 0;
- // students[i] = Student(lastName, numberScorebook, score);
- //}
- }
- void GetArray(Student* students, int size, int scoreSize) {
- int temp[3];// = new int[scoreSize];
- int index = 0;
- for (int i = 0; i < size; i++)
- {
- cout << "Прізвище - " << students[i].lastName << ". Номер залікової книжки - " << students[i].numberScorebook << ". Оцінки - ";
- for (int j = 0; j < scoreSize; j++)
- {
- cout << students[i].score[j] << " ";
- }
- cout << endl;
- }
- }
- void AverageScore(Student* students, int size, int scoreSize) {
- int* tempScore = new int[scoreSize];
- int* tempAverage = new int[size];
- int index = 0;
- int averageScore = 0, sum = 0;
- int j = 0;
- for (int i = 0; i < size; i++)
- {
- cout << "Прізвище - " << students[i].lastName << ". Номер залікової книжки - " << students[i].numberScorebook << ". Оцінки - ";
- for (j = 0; j < scoreSize; j++)
- {
- tempScore[j] = students[i].score[j];
- cout << tempScore[j] << " ";
- sum += tempScore[j];
- }
- //j = 0;
- averageScore = sum / scoreSize;
- tempAverage[i] += averageScore;
- // if(students[i].score[j])
- cout << endl;
- }
- sort(tempAverage, tempAverage + size);
- for (int i = 0; i < size; i++)
- {
- for (j = 0; j < scoreSize; j++)
- {
- //tempScore[j] = students[i].score[j];
- cout << tempScore[j] << " ";
- sum += tempScore[j];
- }
- }
- }
- };
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- const int size = 2;
- Student c[size];//= new Student[size];
- c->AddItemArray(c, size, 3);
- c->GetArray(c, size, 3);
- c->AverageScore(c, size, 3);
- c->GetArray(c, size, 3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment