Advertisement
Guest User

Untitled

a guest
May 24th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. class uchev_plan {
  10. public:
  11. string name_index;
  12. int num_house;
  13. };
  14.  
  15. class group {
  16. public:
  17. int count;
  18. string name_group;
  19. string potok;
  20. int num_potok;
  21. bool occupated;
  22. vector<uchev_plan> kart;
  23. };
  24.  
  25. class auditoria {
  26. public:
  27. int count;
  28. string name;
  29. bool employment; // 1 - занята, 0 - свободна
  30. bool vid_audirorii; // 1 - лекционная, 0 - обычная
  31. vector<string> vid;
  32. };
  33.  
  34. void Load_files(vector<group>& parent1, vector<auditoria>& parent2) {
  35. ifstream loader;
  36. group gr;
  37. uchev_plan up;
  38. auditoria aud;
  39. vector<uchev_plan> temp;
  40. string path = "group.txt";
  41. string path1 = "plan.txt";;
  42. bool flag = true;
  43. loader.open(path);
  44. if (!loader) {
  45. cout << "Файл "<<path<<" не открылся, убедитесь, что файл лежит в папке с программой и перезапустите её\n";
  46. }
  47. string name1;
  48. string name2;
  49. string buf;
  50. int buff;
  51. while (!loader.eof()) {
  52. loader >> buff;
  53. gr.count = buff;
  54. loader >> name1;
  55. gr.name_group = name1;
  56. loader >> buf;
  57. gr.potok = buf;
  58. loader >> buff;
  59. gr.num_potok = buff;
  60. loader >> buff;
  61. gr.occupated = buff;
  62. ifstream plan;
  63. plan.open(path1);
  64. while (!plan.eof()) {
  65. if (flag == true) {
  66. plan >> name2;
  67. flag = false;
  68. }
  69. plan >> buf;
  70. if (buf == "end") {
  71. flag = true;
  72. if (name2 == name1) {
  73. gr.kart = temp;
  74. temp.clear();
  75. }
  76. else {
  77. temp.clear();
  78. }
  79. continue;
  80. }
  81. else {
  82. up.name_index = buf;
  83. plan >> buff;
  84. up.num_house = buff;
  85. temp.push_back(up);
  86. }
  87. }
  88. plan.close();
  89. parent1.push_back(gr);
  90. }
  91. loader.close();
  92. path = "auditoria.txt";
  93. loader.open(path);
  94. if (!loader) {
  95. cout << "Файл " << path << " не открылся, убедитесь, что файл лежит в папке с программой и перезапустите её\n";
  96. }
  97. while (!loader.eof()) {
  98. loader >> buff;
  99. aud.count = buff;
  100. loader >> buf;
  101. aud.name = buf;
  102. loader >> buff;
  103. aud.employment = buff;
  104. loader >> buff;
  105. aud.vid_audirorii = buff;
  106. parent2.push_back(aud);
  107. }
  108. loader.close();
  109.  
  110. }
  111. void print(vector<auditoria>& a)
  112. {
  113. cout << "Auds: \n";
  114. for (vector<auditoria>::iterator it = a.begin(); it != a.end(); ++it) {
  115. cout << it->count << "\t" << it->name << "\t" << it->employment << "\t" << it->vid_audirorii << endl;
  116. }
  117. }
  118. void print(vector<group>& a) // здесь можно увидеть как вызывается учебный план
  119. {
  120. cout << "Groups: \n";
  121. for (vector<group>::iterator it = a.begin(); it != a.end(); ++it) {
  122. cout << it->count << "\t" << it->name_group << "\t" << it->potok << "\t" << it->num_potok << "\t" << it->occupated << endl;
  123. vector<uchev_plan> up;
  124. up = it->kart;
  125. cout << endl<<"Ucheb_plan: \n";
  126. for (vector<uchev_plan>::iterator it = up.begin(); it != up.end(); ++it) {
  127. cout << it->name_index << "\t" << it->num_house << endl;
  128. }
  129. cout << endl;
  130. up.clear();
  131. }
  132.  
  133. }
  134.  
  135. int main()
  136. {
  137. setlocale(LC_ALL, "rus");
  138. vector<group> groups;
  139. vector<auditoria> audiences;
  140. Load_files(groups, audiences);
  141. print(groups);
  142. print(audiences);
  143.  
  144. system("PAUSE");
  145. return 0;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement