Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <locale.h>
- #include <conio.h>
- #include <iostream>
- #include <windows.h>
- using namespace std;
- #define SIZE 5 //КОЛИЧЕСТВО СТУДЕНТОВ
- class Student
- {
- protected:
- char name[20];
- char surname[20];
- int numb;
- public:
- int set()
- {
- cout << "ИМЯ = ";
- cin.getline(name, 20);
- cout << "ФАМИЛИЯ = ";
- cin.getline(surname, 20);
- cout << "Номер зачетной книжки = ";
- cin >> numb;
- cout << endl;
- cin.ignore();
- return numb;
- }
- void print()
- {
- cout << "ИМЯ = " << name << " " << "ФАМИЛИЯ = " << surname << " Номер зачетной книжки = " << numb <<endl;
- }
- };
- class GroupSTUDENT : public Student
- {
- Student A[SIZE];
- int arr[SIZE];
- public:
- //добавление в группу
- void add()
- {
- for (int i = 0; i < SIZE; i++)
- arr[i] = A[i].set();
- }
- //вывод
- void print_gr()
- {
- for (int i = 0; i < SIZE; i++)
- {
- cout << i + 1 << ".";
- A[i].print();
- }
- }
- //изменить информацию
- void change_info(int n)
- {
- arr[n] = A[n].set();
- }
- //сортировка по номеру зачетной книжки
- void sort_gr()
- {
- int min;
- Student t;
- for (int i = 0; i < SIZE - 1; i++)
- {
- min = i;
- for (int j = i + 1; j < SIZE; j++)
- {
- if (arr[j] < arr[min])
- min = j;
- }
- t = A[i];
- A[i] = A[min];
- A[min] = t;
- }
- }
- };
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- setlocale(LC_ALL, "rus");
- GroupSTUDENT GR, q;
- int k, n;
- GR.add();
- system("cls");
- GR.print_gr();
- cout << "Хотите ли вы изменить информацию?" << endl << "1 - изменить весь список студентов" << endl << "2 - изменить информацию о опеделенном студенте" << endl;
- cout << "Остальные кнопки - не менять информацию" << endl;
- cin >> k;
- switch (k)
- {
- case 1:
- GR.add();
- break;
- case 2:
- cout << "Введите номер студента" << endl;
- cin >> n;
- GR.change_info(n-1);
- break;
- }
- system("cls");
- GR.print_gr();
- cout << endl << "Отсортированный список по номерам зачетных книжек" << endl;
- GR.sort_gr();
- GR.print_gr();
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement