Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #include <locale.h>
  2. #include <conio.h>
  3. #include <iostream>
  4. #include <windows.h>
  5. using namespace std;
  6. #define SIZE 5 //КОЛИЧЕСТВО СТУДЕНТОВ
  7. class Student
  8. {
  9. protected:
  10. char name[20];
  11. char surname[20];
  12. int numb;
  13. public:
  14. int set()
  15. {
  16. cout << "ИМЯ = ";
  17. cin.getline(name, 20);
  18. cout << "ФАМИЛИЯ = ";
  19. cin.getline(surname, 20);
  20. cout << "Номер зачетной книжки = ";
  21. cin >> numb;
  22. cout << endl;
  23. cin.ignore();
  24. return numb;
  25. }
  26. void print()
  27. {
  28. cout << "ИМЯ = " << name << " " << "ФАМИЛИЯ = " << surname << " Номер зачетной книжки = " << numb <<endl;
  29. }
  30.  
  31. };
  32. class GroupSTUDENT : public Student
  33. {
  34. Student A[SIZE];
  35. int arr[SIZE];
  36. public:
  37. //добавление в группу
  38. void add()
  39. {
  40. for (int i = 0; i < SIZE; i++)
  41. arr[i] = A[i].set();
  42. }
  43. //вывод
  44. void print_gr()
  45. {
  46. for (int i = 0; i < SIZE; i++)
  47. {
  48. cout << i + 1 << ".";
  49. A[i].print();
  50. }
  51. }
  52. //изменить информацию
  53. void change_info(int n)
  54. {
  55. arr[n] = A[n].set();
  56. }
  57. //сортировка по номеру зачетной книжки
  58. void sort_gr()
  59. {
  60. int min;
  61. Student t;
  62. for (int i = 0; i < SIZE - 1; i++)
  63. {
  64. min = i;
  65. for (int j = i + 1; j < SIZE; j++)
  66. {
  67. if (arr[j] < arr[min])
  68. min = j;
  69. }
  70. t = A[i];
  71. A[i] = A[min];
  72. A[min] = t;
  73. }
  74. }
  75. };
  76. int main()
  77. {
  78. SetConsoleCP(1251);
  79. SetConsoleOutputCP(1251);
  80. setlocale(LC_ALL, "rus");
  81. GroupSTUDENT GR, q;
  82. int k, n;
  83. GR.add();
  84. system("cls");
  85. GR.print_gr();
  86. cout << "Хотите ли вы изменить информацию?" << endl << "1 - изменить весь список студентов" << endl << "2 - изменить информацию о опеделенном студенте" << endl;
  87. cout << "Остальные кнопки - не менять информацию" << endl;
  88. cin >> k;
  89. switch (k)
  90. {
  91. case 1:
  92. GR.add();
  93. break;
  94. case 2:
  95. cout << "Введите номер студента" << endl;
  96. cin >> n;
  97. GR.change_info(n-1);
  98. break;
  99. }
  100. system("cls");
  101. GR.print_gr();
  102. cout << endl << "Отсортированный список по номерам зачетных книжек" << endl;
  103. GR.sort_gr();
  104. GR.print_gr();
  105. _getch();
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement