fork download
  1. #include "Base.h"
  2.  
  3. void Base::menu()
  4. {
  5. system("cls");
  6. cout << "*************************************************************************************************************************************" << endl;
  7. cout << "\n\t\t\t\t\t\tКонтроль успішності учнів ліцею №11\t\t\t\t\t\t\n" << endl;
  8. cout << "*************************************************************************************************************************************" << endl;
  9. cout << "\n\t\t\t\t\t\t\t 1. Перегляд" << endl;
  10. cout << "\t\t\t\t\t\t\t 2. Ввід" << endl;
  11. cout << "\t\t\t\t\t\t\t 3. Редагування" << endl;
  12. cout << "\t\t\t\t\t\t\t 4. Пошук" << endl;
  13. cout << "\t\t\t\t\t\t\t 5. Сортування" << endl;
  14. cout << "\t\t\t\t\t\t\t 6. Видалення" << endl;
  15. cout << "\t\t\t\t\t\t\t 7. Вихід" << endl;
  16.  
  17. a = _getch();
  18. switch (a) {
  19. case '1':
  20. look();
  21. next();
  22. break;
  23. case '2':
  24. enter();
  25. next();
  26. break;
  27. case '3':
  28. redac();
  29. next();
  30. break;
  31. case '4':
  32. poshyk();
  33. next();
  34. break;
  35. case '5':
  36. sort();
  37. next();
  38. break;
  39. case '6':
  40. delet();
  41. next();
  42. break;
  43. case '7':
  44. exit(1);
  45. break;
  46. default:
  47. cout << "Помилка, повторіть ввід!";
  48. }
  49. }
  50. void Base::next()
  51. {
  52. cout << "Для виходу в головне меню натисніть (1)" << endl;
  53. a = _getch();
  54. switch (b) {
  55. case '1':
  56. menu();
  57. break;
  58. case '2':
  59. exit(1);
  60. }
  61. }
  62.  
  63. void Base::provirka()
  64. {
  65. fstream fil;
  66. fil.open(file, ios::out | ios::in | ios::binary);
  67. if (!file) {
  68. cout << " Файл не знайдений !!!" << endl;
  69. system("pause");
  70. }
  71. fil.close();
  72. }
  73.  
  74. void Base::look()
  75. {
  76. system("cls");
  77. Stud ob;
  78. ifstream in;
  79. in.open(file, ios::in | ios::binary);
  80. if (!in) {
  81. cout << "Помилка" << endl;
  82. }
  83. cout << "******************************************************************************************************************************************" << endl;
  84. cout << "|№ | Прізвище | Ім'я | По батькові |Матем.|Укр.мова|Укр.літ|Інформ.|Ін.мова|Укр.історія|Географія|Фізика|Біологія|Фіз-ра|Середн.бал|Клас|" << endl;
  85. while (in.read((char*)&ob, sizeof ob))
  86. cout << "|" << setw(2) << ob.number << "|" << setw(10) << ob.prizv << "|" << setw(8) << ob.name << "|"
  87. << setw(13) << ob.batk << "| " << setw(2) << ob.matem << " | " << setw(2) << ob.ukr_mov << " | "
  88. << setw(2) << ob.ukr_lit << " | " << setw(2) << ob.informatic << " | " << setw(2) << ob.in_mov << " | "
  89. << ob.istor_ukr << " | " << setw(2) << ob.geografiy << " | " << setw(2) << ob.fizika << " | " << setw(2)
  90. << ob.biologia << " | " << setw(2) << ob.fizra << " | " << setw(4)
  91. << setw(2) << ob.seredniy_bal << " | " << setprecision(2) << ob.clas << "|" << endl;
  92. cout << "******************************************************************************************************************************************" << endl;
  93. in.close();
  94. }
  95. void Base::enter()
  96. {
  97. Stud ob;
  98. ofstream out;
  99. out.open(file, ios::out | ios::app | ios::binary);
  100. if (!out) {
  101. cout << "Помилка";
  102. }
  103. system("cls");
  104. cout << "Клас: ";
  105. cin >> ob.clas;
  106. cout << "Особистий номер: ";
  107. cin >> ob.number;
  108. eatline();
  109. cout << "Прізвище: ";
  110. cin.getline(ob.prizv, 15);
  111. cout << "Ім'я: ";
  112. cin.getline(ob.name, 15);
  113. cout << "По батькові: ";
  114. cin.getline(ob.batk, 15);
  115. cout << "Математика: ";
  116. cin >> ob.matem;
  117. cout << "Українська мова: ";
  118. cin >> ob.ukr_mov;
  119. cout << "Українська література: ";
  120. cin >> ob.ukr_lit;
  121. cout << "Іноземна мова: ";
  122. cin >> ob.in_mov;
  123. cout << "Інформатика: ";
  124. cin >> ob.informatic;
  125. cout << "Фізика: ";
  126. cin >> ob.fizika;
  127. cout << "Історія України: ";
  128. cin >> ob.istor_ukr;
  129. cout << "Географія: ";
  130. cin >> ob.geografiy;
  131. cout << "Біологія: ";
  132. cin >> ob.biologia;
  133. cout << "Фіз-ра: ";
  134. cin >> ob.fizra;
  135.  
  136. ob.seredniy_bal = (ob.matem + ob.ukr_mov + ob.informatic + ob.ukr_lit + ob.in_mov + ob.biologia + ob.istor_ukr + ob.fizika + ob.fizra + ob.geografiy) / 10;
  137. eatline();
  138. out.write((char*)&ob, sizeof ob);
  139. out.close();
  140. system("pause");
  141. }
  142. void Base::poshyk()
  143. {
  144. system("cls");
  145. int temp;
  146. Stud ob;
  147. fstream poshyk(file, ios::in | ios::binary);
  148. look();
  149. cout << "Пошук по особистому номером:" << endl;
  150. cin >> temp;
  151. eatline();
  152. while (true) {
  153. poshyk.read((char*)&ob, sizeof(Stud));
  154. if (poshyk.eof()) {
  155. cout << "Немає " << temp << endl;
  156. return;
  157. }
  158. if (temp == ob.number) {
  159. cout << "******************************************************************************************************************************************" << endl;
  160. cout << "|№ | Прізвище | Ім'я | По батькові |Матем.|Укр.мова|Укр.літ|Інформ.|Ін.мова|Укр.історія|Географія|Фізика|Біологія|Фіз-ра|Середн.бал|Клас|" << endl;
  161. cout << "|" << setw(2) << ob.number << " |" << setw(10) << ob.prizv << "|" << setw(8) << ob.name << "|"
  162. << setw(13) << ob.batk << "| " << setw(2) << ob.matem << " | " << setw(2) << ob.ukr_mov << " | "
  163. << setw(2) << ob.ukr_lit << " | " << setw(2) << ob.informatic << " | " << setw(2) << ob.in_mov << " | "
  164. << ob.istor_ukr << " | " << setw(2) << ob.geografiy << " | " << setw(2) << ob.fizika << " | " << setw(2)
  165. << ob.biologia << " | " << setw(2) << ob.fizra << " | " << setw(4)
  166. << setw(2) << ob.seredniy_bal << " | " << setprecision(2) << ob.clas << "|" << endl;
  167. cout << "******************************************************************************************************************************************" << endl;
  168. return;
  169. }
  170. }
  171. }
  172. void Base::sort()
  173. {
  174. system("cls");
  175. fstream sort;
  176. sort.open(file, ios::in | ios::binary);
  177. Stud ob[1000];
  178. Stud tem;
  179. int count = 0;
  180.  
  181. while (!sort.eof()) {
  182. sort.read((char*)&ob[count], sizeof(Stud));
  183. count++;
  184. }
  185. count--;
  186. cout << "Сортування по:\n1 - Особистому номеру\n2 - По прізвищу\nЗ - Середньому балу\n4 - Класу" << endl;
  187. int a;
  188. cin >> a;
  189. eatline();
  190. if (a == 1) {
  191. for (int i = 0; i < count; i++)
  192. for (int j = 0; j < count; j++) {
  193. if (ob[i].number < ob[j].number) {
  194. tem = ob[i];
  195. ob[i] = ob[j];
  196. ob[j] = tem;
  197. }
  198. }
  199. if (a == 2)
  200. for (int i = 0; i < count; i++)
  201. for (int j = 0; j < count; j++)
  202.  
  203. if (ob[i].prizv[0] < ob[j].prizv[0]) {
  204. tem = ob[i];
  205. ob[i] = ob[j];
  206. ob[j] = tem;
  207. }
  208. }
  209.  
  210. if (a == 3)
  211. for (int i = 0; i < count; i++)
  212. for (int j = 0; j < count; j++)
  213.  
  214. if (ob[i].seredniy_bal < ob[j].seredniy_bal) {
  215. tem = ob[i];
  216. ob[i] = ob[j];
  217. ob[j] = tem;
  218. }
  219.  
  220. if (a == 4)
  221. for (int i = 0; i < count; i++)
  222. for (int j = 0; j < count; j++)
  223. if (ob[i].clas[0] < ob[j].clas[0]) {
  224. tem = ob[i];
  225. ob[i] = ob[j];
  226. ob[j] = tem;
  227. }
  228.  
  229. sort.close();
  230. sort.clear();
  231. sort.open(file, ios::out | ios::binary);
  232. for (a = 0; a < count; a++)
  233. sort.write((char*)&ob[a], sizeof(Stud));
  234. sort.close();
  235. cout << "Успішно!" << endl;
  236. }
  237. //////////////////////////////////////////////////
  238. void Base::redac()
  239.  
  240. {
  241. system("cls");
  242. int t = 0;
  243. Stud ob[1000];
  244. fstream del;
  245. del.open(file, ios::in | ios::out | ios::binary);
  246. if (!del.is_open()) {
  247. cout << "Помилка!" << endl;
  248. exit(1);
  249. }
  250. int count = 0;
  251. while (!del.eof()) {
  252. del.read((char*)&ob[count], sizeof(Stud));
  253. count++;
  254. }
  255. look();
  256. count--;
  257. cout << "Введіть особистий номер учня для редагування: ";
  258. double number;
  259. cin >> number;
  260. del.close();
  261. del.clear();
  262. del.open(file, ios::out | ios::binary);
  263. for (int x = 0; x < count; x++)
  264. if (ob[x].number != number)
  265. del.write((char*)&ob[x], sizeof(Stud));
  266. enter();
  267. del.close();
  268. cout << "Успішно!" << endl;
  269. }
  270.  
  271. void Base::delet()
  272. {
  273. system("cls");
  274. int t = 0;
  275. Stud ob[1000];
  276. fstream del;
  277. del.open(file, ios::in | ios::out | ios::binary);
  278. if (!del.is_open()) {
  279. cout << "Помилка!!!" << endl;
  280. exit(1);
  281. }
  282. int count = 0;
  283. while (!del.eof()) {
  284. del.read((char*)&ob[count], sizeof(Stud));
  285. count++;
  286. }
  287. look();
  288. count--;
  289. cout << "Введіть особистий номер учня каторого треба видалити: ";
  290. double number;
  291. cin >> number;
  292. del.close();
  293. del.clear();
  294. del.open(file, ios::out | ios::binary);
  295. for (int x = 0; x < count; x++)
  296. if (ob[x].number != number)
  297. del.write((char*)&ob[x], sizeof(Stud));
  298. del.close();
  299. cout << "Успішно!" << endl;
  300. }
  301.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:10: fatal error: Base.h: No such file or directory
 #include "Base.h"
          ^~~~~~~~
compilation terminated.
stdout
Standard output is empty