Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- #include<string>
- #include<string.h>
- using namespace std;
- struct Student
- {
- int num;
- string fam;
- string nam;
- int stdn;
- string dbd;
- string phone;
- int marks[8];
- Student* next;
- };
- struct Group
- {
- int number;
- int size;
- static Group* head;
- static Group* last;
- static int grcount;
- Student* adr;
- Student* adr_last;
- Group* next;
- Group(int N)
- {
- number = N;
- size = 0;
- head = 0;
- last = 0;
- adr = 0;
- adr_last = 0;
- }
- void add_group(int N);
- void del_group(int N);
- void print_group();
- void search_group(int N);
- };
- Group* Group::head;
- Group* Group::last;
- int Group::grcount;
- void Group::add_group(int N)
- {
- bool k = false;
- Group* temp = head;
- while (temp)
- {
- if (temp->number == N)
- {
- cout << "Такая группа уже существует!";
- k = true;
- }
- temp = temp->next;
- }
- if (!k)
- {
- temp = new Group(N);
- if (last)
- {
- last->next = temp;
- last = temp;
- temp->next = 0;
- }
- else
- {
- head = last = temp;
- }
- grcount++;
- cout << "Новая группа номер " << N << " создана!\n";
- }
- cout << "Нажмите любую кнопку для продолжения!\n";
- _getch();
- system("cls");
- }
- void Group::del_group(int N)
- {
- Group* temp = head;
- Group* prev_temp = 0;
- while (temp)
- {
- if (temp->number == N)
- {
- Student* stud_temp = temp->adr;
- Student* stud_temp2 = 0;
- while (stud_temp)
- {
- stud_temp2 = stud_temp->next;
- delete stud_temp;
- stud_temp = stud_temp2;
- }
- if ((temp->next) && (prev_temp))
- {
- prev_temp->next = temp->next;
- }
- if ((temp->next == 0) && (temp != head))
- {
- last = prev_temp;
- last->next = 0;
- }
- if ((temp == head) && (temp->next))
- {
- head = temp->next;
- }
- if ((temp == head) && (temp == last))
- {
- head = last = 0;
- }
- delete stud_temp;
- grcount--;
- cout << "Группа " << N << " удалена!\n";
- break;
- }
- else if (temp->next == 0)
- {
- cout << "Данной группы не существуеи!\n";
- }
- prev_temp = temp;
- temp = temp->next;
- }
- cout << "Чтобы продолжить нажмите любую кнопку!\n";
- _getch();
- system("cls");
- }
- void Group::print_group()
- {
- Group* temp = head;
- cout << "Список групп: \n\n";
- while (temp)
- {
- cout << "________________________________________________\n";
- cout << "Номер группы: " << temp->number << " \n";
- cout << "Количество человек в группе: " << temp->size << " \n";
- cout << "________________________________________________\n";
- temp = temp->next;
- }
- cout << "Конец списка!\n";
- cout << "Нажмите любую кнопку для продолжения!\n";
- _getch();
- system("cls");
- }
- void Group::search_group(int N)
- {
- Group* temp = head;
- while (temp)
- {
- if (temp->number == N)
- {
- cout << "Группа существует!\n";
- break;
- }
- else if (temp->next == 0)
- {
- cout << "Группа не существует!\n";
- }
- temp = temp->next;
- }
- cout << "Чтобы продолжить нажмите любую кнопку!\n";
- _getch();
- system("cls");
- }
Advertisement
Add Comment
Please, Sign In to add comment