Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.67 KB | None | 0 0
  1. #include "pch.h"
  2. #include <windows.h>
  3. #include<iomanip>
  4. #include<fstream>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <stdlib.h>
  8. #include <string>
  9. #include <iomanip>
  10. #include <conio.h>
  11. using namespace std;
  12.  
  13. struct address
  14. {
  15. int home;
  16. string street;
  17. int flate;
  18. };
  19.  
  20. struct bank {
  21. string surn;
  22. string name;
  23. string ot;
  24. int day;
  25. int month;
  26. int year;
  27. char pol;
  28. struct address ad;
  29. };
  30.  
  31. struct list {
  32. bank inf;
  33. list *next;
  34. list *pre;
  35. };
  36.  
  37. void SetColor(int text, int bg) {
  38. HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  39. SetConsoleTextAttribute(hStdOut, (WORD)((bg << 4) | text));
  40. }
  41.  
  42.  
  43. list* create()
  44. {
  45. system("color 70");
  46. list *temp = new list;
  47. cout << "Введите данные для первого элемента в списке\n";
  48. cout << "\nВведите фамилию\n";
  49. cin>>temp->inf.surn;
  50. cout << "\nВведите имя\n";
  51. cin >> temp->inf.name;
  52. cout << "\nВведите отчество\n";
  53. cin >> temp->inf.ot;
  54. cout << "\nВведите день рождения\n";
  55. cin >> temp->inf.day;
  56. if (temp->inf.day > 31 || temp->inf.day < 1)
  57. {
  58. cout << "\nТакого числа не существует\n";
  59. system("pause");
  60. delete temp;
  61. return 0;
  62. }
  63. cout << "\nВведите месяц рождения\n";
  64. cin >> temp->inf.month;
  65. if (temp->inf.month > 12 || temp->inf.day < 1)
  66. {
  67. cout << "Введено неверное число\n";
  68. system("pause");
  69. delete temp;
  70. return 0;
  71. }
  72. if (temp->inf.month == 2 && temp->inf.day > 29)
  73. {
  74. cout << "\nВ феврале на может быть больше 29 дней\n";
  75. system("pause");
  76. delete temp;
  77. return 0;
  78. }
  79. else
  80. {
  81. if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
  82. {
  83. cout << "\nТакой даты не сущетсвует\n";
  84. system("pause");
  85. delete temp;
  86. return 0;
  87. }
  88. }
  89. cout << "\nВведите год рождения\n";
  90. cin >> temp->inf.year;
  91. if (temp->inf.year < 1950 || temp->inf.year>5000)
  92. {
  93. cout << "\nВведен неверный год\n";
  94. system("pause");
  95. delete temp;
  96. return 0;
  97. }
  98. if (temp->inf.month == 2 && temp->inf.year % 4 != 0 && temp->inf.day==29)
  99. {
  100. cout << "Увы, это не високосный год\n";
  101. system("pause");
  102. delete temp;
  103. return 0;
  104. }
  105. cout << "\nВведите пол\n";
  106. cout<<"Подсказка:(w/m)\n";
  107. cin >> temp->inf.pol;
  108. if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
  109. {
  110. cout << "\nВы ввели не верный символ\n";
  111. system("pause");
  112. delete temp;
  113. return 0;
  114. }
  115. cout << "\nВведите улицу\n";
  116. cin >> temp->inf.ad.street;
  117. cout << "\nВведите номер дома\n" << endl;
  118. cin >> temp->inf.ad.home;
  119. if (temp->inf.ad.home<1)
  120. {
  121. cout << "\nВы ввели не верное число\n";
  122. system("pause");
  123. delete temp;
  124. return 0;
  125. }
  126. cout << "\nВведите номер квартиры\n";
  127. cin >> temp->inf.ad.flate;
  128. if (temp->inf.ad.flate < 1)
  129. {
  130. cout << "\nВы ввели не верное число\n";
  131. system("pause");
  132. delete temp;
  133. return 0;
  134. }
  135. temp->next = NULL;
  136. temp->pre = NULL;
  137. return temp;
  138. }
  139. list* dob_second(list *l)
  140. {
  141. list *temp;
  142. temp = l->next;
  143. temp = new list;
  144. cout << "Введите данные для второго элемента в списке\n";
  145. cout << "\nВведите фамилию\n";
  146. cin >> temp->inf.surn;
  147. cout << "\nВведите имя\n";
  148. cin >> temp->inf.name;
  149. cout << "\nВведите отчество\n";
  150. cin >> temp->inf.ot;
  151. cout << "\nВведите день рождения\n";
  152. cin >> temp->inf.day;
  153. if (temp->inf.day > 31 || temp->inf.day < 1)
  154. {
  155. cout << "\nТакого числа не существует\n";
  156. system("pause");
  157. delete temp;
  158. l->next = NULL;
  159. l->pre = NULL;
  160. return l;
  161. }
  162. cout << "\nВведите месяц рождения\n";
  163. cin >> temp->inf.month;
  164. if (temp->inf.month > 12 || temp->inf.day < 1)
  165. {
  166. cout << "Введено неверное число\n";
  167. system("pause");
  168. delete temp;
  169. l->next = NULL;
  170. l->pre = NULL;
  171. return l;
  172. }
  173. if (temp->inf.month == 2 && temp->inf.day > 29)
  174. {
  175. cout << "\nВ феврале на может быть больше 29 дней\n";
  176. system("pause");
  177. delete temp;
  178. l->next = NULL;
  179. l->pre = NULL;
  180. return l;
  181. }
  182. else
  183. {
  184. if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
  185. {
  186. cout << "\nТакой даты не сущетсвует\n";
  187. system("pause");
  188. delete temp;
  189. l->next = NULL;
  190. l->pre = NULL;
  191. return l;
  192. }
  193. }
  194. cout << "\nВведите год рождения\n";
  195. cin >> temp->inf.year;
  196. if (temp->inf.year < 1950 || temp->inf.year>5000)
  197. {
  198. cout << "\nВведен неверный год\n";
  199. system("pause");
  200. delete temp;
  201. l->next = NULL;
  202. l->pre = NULL;
  203. return l;
  204. }
  205. cout << "\nВведите пол\n";
  206. cout << "Подсказка:(w/m)\n";
  207. cin >> temp->inf.pol;
  208. if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
  209. {
  210. cout << "\nВы ввели не верный символ\n";
  211. system("pause");
  212. delete temp;
  213. l->next = NULL;
  214. l->pre = NULL;
  215. return l;
  216. }
  217. cout << "\nВведите улицу\n";
  218. cin >> temp->inf.ad.street;
  219. cout << "\nВведите номер дома\n" << endl;
  220. cin >> temp->inf.ad.home;
  221. if (temp->inf.ad.home < 1)
  222. {
  223. cout << "\nВы ввели не верное число\n";
  224. system("pause");
  225. delete temp;
  226. l->next = NULL;
  227. l->pre = NULL;
  228. return l;
  229. }
  230. cout << "\nВведите номер квартиры\n";
  231. cin >> temp->inf.ad.flate;
  232. if (temp->inf.ad.flate < 1)
  233. {
  234. cout << "\nВы ввели не верное число\n";
  235. system("pause");
  236. delete temp;
  237. l->next = NULL;
  238. l->pre = NULL;
  239. return l;
  240. }
  241. temp->pre = l;
  242. temp->next = NULL;
  243. return temp;
  244. }
  245. list* add(list *r)
  246. {
  247. list *pr;
  248. pr = r;
  249. list *temp= new list;
  250. r->next = temp;
  251. cout << "Введите данные элемента в списке\n";
  252. cout << "\nВведите фамилию\n";
  253. cin >> temp->inf.surn;
  254. cout << "\nВведите имя\n";
  255. cin >> temp->inf.name;
  256. cout << "\nВведите отчество\n";
  257. cin >> temp->inf.ot;
  258. cout << "\nВведите день рождения\n";
  259. cin >> temp->inf.day;
  260. if (temp->inf.day > 31 || temp->inf.day < 1)
  261. {
  262. cout << "\nТакого числа не существует\n";
  263. system("pause");
  264. delete temp;
  265. return pr;
  266. }
  267. cout << "\nВведите месяц рождения\n";
  268. cin >> temp->inf.month;
  269. if (temp->inf.month > 12 || temp->inf.day < 1)
  270. {
  271. cout << "Введено неверное число\n";
  272. system("pause");
  273. delete temp;
  274. return pr;
  275. }
  276. if (temp->inf.month == 2 && temp->inf.day > 29)
  277. {
  278. cout << "\nВ феврале на может быть больше 29 дней\n";
  279. system("pause");
  280. delete temp;
  281. return pr;
  282. }
  283. else
  284. {
  285. if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
  286. {
  287. cout << "\nТакой даты не сущетсвует\n";
  288. system("pause");
  289. delete temp;
  290. return pr;
  291. }
  292. }
  293. cout << "\nВведите год рождения\n";
  294. cin >> temp->inf.year;
  295. if (temp->inf.year < 1950 || temp->inf.year>5000)
  296. {
  297. cout << "\nВведен неверный год\n";
  298. system("pause");
  299. delete temp;
  300. return pr;
  301. }
  302. cout << "\nВведите пол\n";
  303. cout << "Подсказка:(w/m)\n";
  304. cin >> temp->inf.pol;
  305. if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
  306. {
  307. cout << "\nВы ввели не верный символ\n";
  308. system("pause");
  309. delete temp;
  310. return pr;
  311. }
  312. cout << "\nВведите улицу\n";
  313. cin >> temp->inf.ad.street;
  314. cout << "\nВведите номер дома\n" << endl;
  315. cin >> temp->inf.ad.home;
  316. if (temp->inf.ad.home < 1)
  317. {
  318. cout << "\nВы ввели не верное число\n";
  319. system("pause");
  320. delete temp;
  321. return pr;
  322. }
  323. cout << "\nВведите номер квартиры\n";
  324. cin >> temp->inf.ad.flate;
  325. if (temp->inf.ad.flate < 1)
  326. {
  327. cout << "\nВы ввели не верное число\n";
  328. system("pause");
  329. delete temp;
  330. return pr;
  331. }
  332. temp->pre = r;
  333. temp->next = NULL;
  334. return temp;
  335. }
  336. void show(list *l, list *r)
  337. {
  338. char c1;
  339. list *temp;
  340. temp = l;
  341. if (l == NULL)
  342. {
  343. cout << "\nЭлементов нет\n";
  344. system("pause");
  345. return;
  346. }
  347. else {
  348. if (l == r)
  349. {
  350. cout << "Фамилия " << temp->inf.surn << endl;
  351. cout << "Имя " << temp->inf.name << endl;
  352. cout << "Отчество " << temp->inf.ot << endl;
  353. cout << "День рождения " << temp->inf.day << endl;
  354. cout << "Месяц рождения " << temp->inf.month << endl;
  355. cout << "Год рождения " << temp->inf.year << endl;
  356. cout << "Пол " << temp->inf.pol << endl;
  357. cout << "Улица " << temp->inf.ad.street << endl;
  358. cout << "Дом " << temp->inf.ad.home << endl;
  359. cout << "Квартира " << temp->inf.ad.flate << endl;
  360. cout << "\n";
  361. return;
  362. }
  363. else
  364. {
  365. cout << "===================================================" << endl;
  366. cout << "Просмотр с первого" << endl;
  367. cout << "Просмотр с последнего " << endl;
  368. cout << "===================================================" << endl;
  369. cin >> c1;
  370. if (c1 == '1')
  371. {
  372. temp = l;
  373. cout << "\nОсуществляется просмотр сначала\n";
  374. for (; temp != r->next; temp = temp->next)
  375. {
  376. cout << "Фамилия " <<temp->inf.surn <<endl;
  377. cout << "Имя " << temp->inf.name <<endl;
  378. cout << "Отчество " << temp->inf.ot <<endl;
  379. cout << "День рождения " <<temp->inf.day <<endl;
  380. cout << "Месяц рождения " << temp->inf.month<<endl;
  381. cout << "Год рождения " << temp->inf.year<<endl;
  382. cout << "Пол " << temp->inf.pol<<endl;
  383. cout << "Улица " << temp->inf.ad.street<<endl;
  384. cout << "Дом "<< temp->inf.ad.home<<endl;
  385. cout << "Квартира " << temp->inf.ad.flate <<endl;
  386. cout << "\n";
  387. }
  388. }
  389. else
  390. {
  391. if (c1 == '2')
  392. {
  393. temp = r;
  394. cout << "\nОсуществляется просмотр с конца\n";
  395. for (; temp != NULL; temp = temp->pre)
  396. {
  397. cout << "Фамилия " << temp->inf.surn << endl;
  398. cout << "Имя " << temp->inf.name << endl;
  399. cout << "Отчество " << temp->inf.ot << endl;
  400. cout << "День рождения " << temp->inf.day << endl;
  401. cout << "Месяц рождения " << temp->inf.month << endl;
  402. cout << "Год рождения " << temp->inf.year << endl;
  403. cout << "Пол " << temp->inf.pol << endl;
  404. cout << "Улица " << temp->inf.ad.street << endl;
  405. cout << "Дом " << temp->inf.ad.home << endl;
  406. cout << "Квартира " << temp->inf.ad.flate << endl;
  407. cout << "\n";
  408. }
  409. }
  410. }
  411. }
  412. }
  413. }
  414. list* del_first(list *l,list *r)
  415. {
  416. list *temp;
  417. if (l == NULL)
  418. {
  419. cout << "\nСписок пуст\n";
  420. system("pause");
  421. return NULL;
  422. }
  423. if (l->next == NULL)
  424. {
  425. delete l;
  426. l = NULL;
  427. cout << "\nЭлемент удален\n";
  428. system("pause");
  429. return NULL;
  430. }
  431. else
  432. {
  433. temp = l;
  434. l = temp->next;
  435. temp->next = NULL;
  436. delete temp;
  437. return l;
  438. }
  439. }
  440. list* del_last(list *r)
  441. {
  442. list* temp;
  443. temp = r;
  444. r = temp->pre;
  445. delete temp;
  446. r->next = NULL;
  447. return r;
  448. }
  449. void sohr(list *l,list *r)
  450. {
  451.  
  452. }
  453. void search(list *l, list *r, int pois)
  454. {//от 49
  455. string str1;
  456. int ko;
  457. char ey;
  458. list *temp;
  459. temp = l;
  460. if (pois == 49 || pois == 50 || pois == 51)
  461. {
  462. if (pois == 49)
  463. {
  464. cout << "\nВведите фамилию\n";
  465. cin >> str1;
  466. for (; temp != NULL; temp = temp->next)
  467. {
  468. if (temp->inf.surn == str1)
  469. {
  470. cout << "Найден клиент с такими данными" << endl;
  471. cout << "Информация\n\n";
  472. cout << "Фамилия " << temp->inf.surn << endl;
  473. cout << "Имя " << temp->inf.name << endl;
  474. cout << "Отчество " << temp->inf.ot << endl;
  475. cout << "День рождения " << temp->inf.day << endl;
  476. cout << "Месяц рождения " << temp->inf.month << endl;
  477. cout << "Год рождения " << temp->inf.year << endl;
  478. cout << "Пол " << temp->inf.pol << endl;
  479. cout << "Улица " << temp->inf.ad.street << endl;
  480. cout << "Дом " << temp->inf.ad.home << endl;
  481. cout << "Квартира " << temp->inf.ad.flate << endl;
  482. }
  483. }
  484. system("pause");
  485. }
  486. if (pois == 50)
  487. {
  488. cout << "\nВведите имя\n";
  489. cin >> str1;
  490. for (; temp != NULL; temp = temp->next)
  491. {
  492. if (temp->inf.name == str1)
  493. {
  494. cout << "Найден клиент с такими данными" << endl;
  495. cout << "Информация\n\n";
  496. cout << "Фамилия " << temp->inf.surn << endl;
  497. cout << "Имя " << temp->inf.name << endl;
  498. cout << "Отчество " << temp->inf.ot << endl;
  499. cout << "День рождения " << temp->inf.day << endl;
  500. cout << "Месяц рождения " << temp->inf.month << endl;
  501. cout << "Год рождения " << temp->inf.year << endl;
  502. cout << "Пол " << temp->inf.pol << endl;
  503. cout << "Улица " << temp->inf.ad.street << endl;
  504. cout << "Дом " << temp->inf.ad.home << endl;
  505. cout << "Квартира " << temp->inf.ad.flate << endl;
  506. }
  507. }
  508. system("pause");
  509. }
  510. if (pois == 51)
  511. {
  512. cout << "\nВведите отчество\n";
  513. cin >> str1;
  514. for (; temp != NULL; temp = temp->next)
  515. {
  516. if (temp->inf.ot == str1)
  517. {
  518. cout << "Найден клиент с такими данными" << endl;
  519. cout << "Информация\n\n";
  520. cout << "Фамилия " << temp->inf.surn << endl;
  521. cout << "Имя " << temp->inf.name << endl;
  522. cout << "Отчество " << temp->inf.ot << endl;
  523. cout << "День рождения " << temp->inf.day << endl;
  524. cout << "Месяц рождения " << temp->inf.month << endl;
  525. cout << "Год рождения " << temp->inf.year << endl;
  526. cout << "Пол " << temp->inf.pol << endl;
  527. cout << "Улица " << temp->inf.ad.street << endl;
  528. cout << "Дом " << temp->inf.ad.home << endl;
  529. cout << "Квартира " << temp->inf.ad.flate << endl;
  530. }
  531. }
  532. system("pause");
  533. }
  534. }
  535. else
  536. {
  537. if (pois == 52 || pois == 53 || pois == 54 || pois == 55)
  538. {
  539. if (pois == 52)
  540. {
  541. cout << "\nВведите день рождения\n";
  542. cin >> ko;
  543. for (; temp != NULL; temp = temp->next)
  544. {
  545. if (temp->inf.day == ko)
  546. {
  547. cout << "Найден клиент с такими данными" << endl;
  548. cout << "Информация\n\n";
  549. cout << "Фамилия " << temp->inf.surn << endl;
  550. cout << "Имя " << temp->inf.name << endl;
  551. cout << "Отчество " << temp->inf.ot << endl;
  552. cout << "День рождения " << temp->inf.day << endl;
  553. cout << "Месяц рождения " << temp->inf.month << endl;
  554. cout << "Год рождения " << temp->inf.year << endl;
  555. cout << "Пол " << temp->inf.pol << endl;
  556. cout << "Улица " << temp->inf.ad.street << endl;
  557. cout << "Дом " << temp->inf.ad.home << endl;
  558. cout << "Квартира " << temp->inf.ad.flate << endl;
  559. }
  560. }
  561. system("pause");
  562. }
  563. if (pois == 53)
  564. {
  565. cout << "\nВведите месяц рождения\n";
  566. cin >> ko;
  567. for (; temp != NULL; temp = temp->next)
  568. {
  569. if (temp->inf.month == ko)
  570. {
  571. cout << "Найден клиент с такими данными" << endl;
  572. cout << "Информация\n\n";
  573. cout << "Фамилия " << temp->inf.surn << endl;
  574. cout << "Имя " << temp->inf.name << endl;
  575. cout << "Отчество " << temp->inf.ot << endl;
  576. cout << "День рождения " << temp->inf.day << endl;
  577. cout << "Месяц рождения " << temp->inf.month << endl;
  578. cout << "Год рождения " << temp->inf.year << endl;
  579. cout << "Пол " << temp->inf.pol << endl;
  580. cout << "Улица " << temp->inf.ad.street << endl;
  581. cout << "Дом " << temp->inf.ad.home << endl;
  582. cout << "Квартира " << temp->inf.ad.flate << endl;
  583. }
  584.  
  585. }
  586. system("pause");
  587. }
  588. if (pois == 54)
  589. {
  590. cout << "\nВведите год рождения\n";
  591. cin >> ko;
  592. for (; temp != NULL; temp = temp->next)
  593. {
  594. if (temp->inf.year == ko)
  595. {
  596. cout << "Найден клиент с такими данными" << endl;
  597. cout << "Информация\n\n";
  598. cout << "Фамилия " << temp->inf.surn << endl;
  599. cout << "Имя " << temp->inf.name << endl;
  600. cout << "Отчество " << temp->inf.ot << endl;
  601. cout << "День рождения " << temp->inf.day << endl;
  602. cout << "Месяц рождения " << temp->inf.month << endl;
  603. cout << "Год рождения " << temp->inf.year << endl;
  604. cout << "Пол " << temp->inf.pol << endl;
  605. cout << "Улица " << temp->inf.ad.street << endl;
  606. cout << "Дом " << temp->inf.ad.home << endl;
  607. cout << "Квартира " << temp->inf.ad.flate << endl;
  608. }
  609.  
  610. }
  611. system("pause");
  612. }
  613. if (pois == 55)
  614. {
  615. cout << "\nВведите пол\n";
  616. cin >> ey;
  617. for (; temp != NULL; temp = temp->next)
  618. {
  619. if (temp->inf.pol == ey)
  620. {
  621. cout << "Найден клиент с такими данными" << endl;
  622. cout << "Информация\n\n";
  623. cout << "Фамилия " << temp->inf.surn << endl;
  624. cout << "Имя " << temp->inf.name << endl;
  625. cout << "Отчество " << temp->inf.ot << endl;
  626. cout << "День рождения " << temp->inf.day << endl;
  627. cout << "Месяц рождения " << temp->inf.month << endl;
  628. cout << "Год рождения " << temp->inf.year << endl;
  629. cout << "Пол " << temp->inf.pol << endl;
  630. cout << "Улица " << temp->inf.ad.street << endl;
  631. cout << "Дом " << temp->inf.ad.home << endl;
  632. cout << "Квартира " << temp->inf.ad.flate << endl;
  633. }
  634. }
  635. system("pause");
  636. }
  637. }
  638. else
  639. {
  640. if (pois == 105)
  641. {
  642. cout << "Введите улицу\n";
  643. cin >> str1;
  644. for (; temp != NULL; temp = temp->next)
  645. {
  646. if (temp->inf.ad.street == str1)
  647. {
  648. cout << "Найден клиент с такими данными" << endl;
  649. cout << "Информация\n\n";
  650. cout << "Фамилия " << temp->inf.surn << endl;
  651. cout << "Имя " << temp->inf.name << endl;
  652. cout << "Отчество " << temp->inf.ot << endl;
  653. cout << "День рождения " << temp->inf.day << endl;
  654. cout << "Месяц рождения " << temp->inf.month << endl;
  655. cout << "Год рождения " << temp->inf.year << endl;
  656. cout << "Пол " << temp->inf.pol << endl;
  657. cout << "Улица " << temp->inf.ad.street << endl;
  658. cout << "Дом " << temp->inf.ad.home << endl;
  659. cout << "Квартира " << temp->inf.ad.flate << endl;
  660. }
  661. }
  662. }
  663. if (pois == 106)
  664. {
  665. cout << "Введите номер дома\n";
  666. cin >> ko;
  667. for (; temp != NULL; temp = temp->next)
  668. {
  669. if (temp->inf.ad.home == ko)
  670. {
  671. cout << "Найден клиент с такими данными" << endl;
  672. cout << "Информация\n\n";
  673. cout << "Фамилия " << temp->inf.surn << endl;
  674. cout << "Имя " << temp->inf.name << endl;
  675. cout << "Отчество " << temp->inf.ot << endl;
  676. cout << "День рождения " << temp->inf.day << endl;
  677. cout << "Месяц рождения " << temp->inf.month << endl;
  678. cout << "Год рождения " << temp->inf.year << endl;
  679. cout << "Пол " << temp->inf.pol << endl;
  680. cout << "Улица " << temp->inf.ad.street << endl;
  681. cout << "Дом " << temp->inf.ad.home << endl;
  682. cout << "Квартира " << temp->inf.ad.flate << endl;
  683. }
  684. }
  685. }
  686. if (pois == 107)
  687. {
  688. cout << "Введите номер квартиры\n";
  689. cin >> ko;
  690. for (; temp != NULL; temp = temp->next)
  691. {
  692. if (temp->inf.ad.flate == ko)
  693. {
  694. cout << "Найден клиент с такими данными" << endl;
  695. cout << "Информация\n\n";
  696. cout << "Фамилия " << temp->inf.surn << endl;
  697. cout << "Имя " << temp->inf.name << endl;
  698. cout << "Отчество " << temp->inf.ot << endl;
  699. cout << "День рождения " << temp->inf.day << endl;
  700. cout << "Месяц рождения " << temp->inf.month << endl;
  701. cout << "Год рождения " << temp->inf.year << endl;
  702. cout << "Пол " << temp->inf.pol << endl;
  703. cout << "Улица " << temp->inf.ad.street << endl;
  704. cout << "Дом " << temp->inf.ad.home << endl;
  705. cout << "Квартира " << temp->inf.ad.flate << endl;
  706. }
  707. }
  708. }
  709. }
  710. }
  711. }
  712. void tabl_show(list *l, list *r)
  713. {
  714. system("color 80");
  715. list* temp,*temp1,*temp2;
  716. string str4;
  717. cout <<setw(10)<< "Фамилия" << setw(10) << "Имя" << setw(18) << "Отчество" << setw(10) << "День" << setw(13) << "Месяц" << setw(10) << "Год" << setw(10) << "Пол" << setw(18) << "Улица" << setw(10) << "Дом" << setw(15) << "Квартира" <<setw(10)<< endl;
  718. cout << "_______________________________________________________________________________________________________________________________\n";
  719. for (temp = l; temp != NULL; temp = temp->next)
  720. {
  721. if (temp != l)
  722. {
  723. cout << "|----------+----------+------------------+----------+----------+----------+----------+------------------+----------+----------|\n";
  724. cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(18) << temp->inf.ot << "|" << setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
  725. }
  726. if(temp==l)
  727. cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(18)<< temp->inf.ot << "|"<< setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
  728. }
  729. cout << "-------------------------------------------------------------------------------------------------------------------------------\n";
  730. if (l != NULL)
  731. {
  732. cout << "\n\nСделать сортировку по фамилии?(Yes/No)\n";
  733. cin >> str4;
  734. if ("Yes" == str4 || "y" == str4 || "Y" == str4)
  735. {
  736. for (temp1 = l; temp1; temp1 = temp1->next)
  737. for (temp2 = temp1; temp2; temp2 = temp2->next)
  738. if (temp1->inf.surn > temp2->inf.surn)
  739. swap(temp1->inf, temp2->inf);
  740. system("cls");
  741. cout << setw(10) << "Фамилия" << setw(10) << "Имя" << setw(15) << "Отчество" << setw(10) << "День" << setw(13) << "Месяц" << setw(10) << "Год" << setw(10) << "Пол" << setw(18) << "Улица" << setw(10) << "Дом" << setw(15) << "Квартира" << setw(10) << endl;
  742. cout << "__________________________________________________________________________________________________________________________\n";
  743. for (temp = l; temp != NULL; temp = temp->next)
  744. {
  745. if (temp != l)
  746. {
  747. cout << "|----------+----------+---------------+----------+----------+----------+----------+---------------+----------+----------|\n";
  748. cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(15) << temp->inf.ot << "|" << setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
  749. }
  750. if (temp == l)
  751. cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(15) << temp->inf.ot << "|" << setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
  752. }
  753. cout << "-------------------------------------------------------------------------------------------------------------------------\n";
  754. }
  755. }
  756. system("pause");
  757. return;
  758. }
  759. void redak2(list *temp, list *zapas)
  760. {
  761. cout << "Введите новые данные\n";
  762. zapas->inf.surn = temp->inf.surn;
  763. zapas->inf.name = temp->inf.name;
  764. zapas->inf.ot = temp->inf.ot;
  765. zapas->inf.day = temp->inf.day;
  766. zapas->inf.month = temp->inf.month;
  767. zapas->inf.year = temp->inf.year;
  768. zapas->inf.pol = temp->inf.pol;
  769. zapas->inf.ad.street = temp->inf.ad.street;
  770. zapas->inf.ad.home = temp->inf.ad.home;
  771. zapas->inf.ad.flate = temp->inf.ad.flate;
  772. cout << "Введите фамилию\n";
  773. cin >> temp->inf.surn;
  774. cout << "Введите имя\n";
  775. cin >> temp->inf.name;
  776. cout << "Введите отчество\n";
  777. cin >> temp->inf.ot;
  778. cout << "Введите день рождения\n";
  779. cin >> temp->inf.day;
  780. if (temp->inf.day > 31 || temp->inf.day < 1)
  781. {
  782. cout << "\nТакого числа не существует\n";
  783. system("pause");
  784. temp->inf.surn = zapas->inf.surn;
  785. temp->inf.name = zapas->inf.name;
  786. temp->inf.ot = zapas->inf.ot;
  787. temp->inf.day = zapas->inf.day;
  788. temp->inf.month = zapas->inf.month;
  789. temp->inf.year = zapas->inf.year;
  790. temp->inf.pol = zapas->inf.pol;
  791. temp->inf.ad.street = zapas->inf.ad.street;
  792. temp->inf.ad.home = zapas->inf.ad.home;
  793. temp->inf.ad.flate = zapas->inf.ad.flate;
  794. return;
  795. }
  796. cout << "Введите месяц рождения\n";
  797. cin >> temp->inf.month;
  798. if (temp->inf.month > 12 || temp->inf.day < 1)
  799. {
  800. cout << "Введено неверное число\n";
  801. system("pause");
  802. temp->inf.surn = zapas->inf.surn;
  803. temp->inf.name = zapas->inf.name;
  804. temp->inf.ot = zapas->inf.ot;
  805. temp->inf.day = zapas->inf.day;
  806. temp->inf.month = zapas->inf.month;
  807. temp->inf.year = zapas->inf.year;
  808. temp->inf.pol = zapas->inf.pol;
  809. temp->inf.ad.street = zapas->inf.ad.street;
  810. temp->inf.ad.home = zapas->inf.ad.home;
  811. temp->inf.ad.flate = zapas->inf.ad.flate;
  812. return;
  813. }
  814. if (temp->inf.month == 2 && temp->inf.day > 29)
  815. {
  816. cout << "\nВ феврале на может быть больше 29 дней\n";
  817. system("pause");
  818. temp->inf.surn = zapas->inf.surn;
  819. temp->inf.name = zapas->inf.name;
  820. temp->inf.ot = zapas->inf.ot;
  821. temp->inf.day = zapas->inf.day;
  822. temp->inf.month = zapas->inf.month;
  823. temp->inf.year = zapas->inf.year;
  824. temp->inf.pol = zapas->inf.pol;
  825. temp->inf.ad.street = zapas->inf.ad.street;
  826. temp->inf.ad.home = zapas->inf.ad.home;
  827. temp->inf.ad.flate = zapas->inf.ad.flate;
  828. return;
  829. }
  830. else
  831. {
  832. if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
  833. {
  834. cout << "\nТакой даты не сущетсвует\n";
  835. system("pause");
  836. temp->inf.surn = zapas->inf.surn;
  837. temp->inf.name = zapas->inf.name;
  838. temp->inf.ot = zapas->inf.ot;
  839. temp->inf.day = zapas->inf.day;
  840. temp->inf.month = zapas->inf.month;
  841. temp->inf.year = zapas->inf.year;
  842. temp->inf.pol = zapas->inf.pol;
  843. temp->inf.ad.street = zapas->inf.ad.street;
  844. temp->inf.ad.home = zapas->inf.ad.home;
  845. temp->inf.ad.flate = zapas->inf.ad.flate;
  846. return;
  847. }
  848. }
  849. cout << "\nВведите год рождения\n";
  850. cin >> temp->inf.year;
  851. if (temp->inf.year < 1950 || temp->inf.year>5000)
  852. {
  853. cout << "\nВведен неверный год\n";
  854. system("pause");
  855. temp->inf.surn = zapas->inf.surn;
  856. temp->inf.name = zapas->inf.name;
  857. temp->inf.ot = zapas->inf.ot;
  858. temp->inf.day = zapas->inf.day;
  859. temp->inf.month = zapas->inf.month;
  860. temp->inf.year = zapas->inf.year;
  861. temp->inf.pol = zapas->inf.pol;
  862. temp->inf.ad.street = zapas->inf.ad.street;
  863. temp->inf.ad.home = zapas->inf.ad.home;
  864. temp->inf.ad.flate = zapas->inf.ad.flate;
  865. return;
  866. }
  867. if (temp->inf.month == 2 && temp->inf.year % 4 != 0 && temp->inf.day == 29)
  868. {
  869. cout << "Увы, это не високосный год\n";
  870. system("pause");
  871. temp->inf.surn = zapas->inf.surn;
  872. temp->inf.name = zapas->inf.name;
  873. temp->inf.ot = zapas->inf.ot;
  874. temp->inf.day = zapas->inf.day;
  875. temp->inf.month = zapas->inf.month;
  876. temp->inf.year = zapas->inf.year;
  877. temp->inf.pol = zapas->inf.pol;
  878. temp->inf.ad.street = zapas->inf.ad.street;
  879. temp->inf.ad.home = zapas->inf.ad.home;
  880. temp->inf.ad.flate = zapas->inf.ad.flate;
  881. return;
  882. }
  883. cout << "\nВведите пол\n";
  884. cout << "Подсказка:(w/m)\n";
  885. cin >> temp->inf.pol;
  886. if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
  887. {
  888. cout << "\nВы ввели не верный символ\n";
  889. system("pause");
  890. temp->inf.surn = zapas->inf.surn;
  891. temp->inf.name = zapas->inf.name;
  892. temp->inf.ot = zapas->inf.ot;
  893. temp->inf.day = zapas->inf.day;
  894. temp->inf.month = zapas->inf.month;
  895. temp->inf.year = zapas->inf.year;
  896. temp->inf.pol = zapas->inf.pol;
  897. temp->inf.ad.street = zapas->inf.ad.street;
  898. temp->inf.ad.home = zapas->inf.ad.home;
  899. temp->inf.ad.flate = zapas->inf.ad.flate;
  900. return;
  901. }
  902. cout << "\nВведите улицу\n";
  903. cin >> temp->inf.ad.street;
  904. cout << "\nВведите номер дома\n" << endl;
  905. cin >> temp->inf.ad.home;
  906. if (temp->inf.ad.home < 1)
  907. {
  908. cout << "\nВы ввели не верное число\n";
  909. system("pause");
  910. temp->inf.surn = zapas->inf.surn;
  911. temp->inf.name = zapas->inf.name;
  912. temp->inf.ot = zapas->inf.ot;
  913. temp->inf.day = zapas->inf.day;
  914. temp->inf.month = zapas->inf.month;
  915. temp->inf.year = zapas->inf.year;
  916. temp->inf.pol = zapas->inf.pol;
  917. temp->inf.ad.street = zapas->inf.ad.street;
  918. temp->inf.ad.home = zapas->inf.ad.home;
  919. temp->inf.ad.flate = zapas->inf.ad.flate;
  920. return;
  921. }
  922. cout << "\nВведите номер квартиры\n";
  923. cin >> temp->inf.ad.flate;
  924. if (temp->inf.ad.flate < 1)
  925. {
  926. cout << "\nВы ввели не верное число\n";
  927. system("pause");
  928. temp->inf.surn = zapas->inf.surn;
  929. temp->inf.name = zapas->inf.name;
  930. temp->inf.ot = zapas->inf.ot;
  931. temp->inf.day = zapas->inf.day;
  932. temp->inf.month = zapas->inf.month;
  933. temp->inf.year = zapas->inf.year;
  934. temp->inf.pol = zapas->inf.pol;
  935. temp->inf.ad.street = zapas->inf.ad.street;
  936. temp->inf.ad.home = zapas->inf.ad.home;
  937. temp->inf.ad.flate = zapas->inf.ad.flate;
  938. return;
  939. }
  940. cout << "Данные отредактированы\n";
  941. system("pause");
  942. }
  943. void redakt(list *l, list *r)
  944. {//по номеру элемента или по полю
  945. list *temp, *zapas;
  946. char q, q1;
  947. zapas = new list;
  948. int w, t;
  949. string str1;
  950. temp = l;
  951. if (l == NULL)
  952. {
  953. cout << "Список пуст\n";
  954. system("pause");
  955. return;
  956. }
  957. cout << "\nВыберите способ редктирования\n";
  958. cout << "1 Редактирование по номеру элемента\n";
  959. cout << "2 Редактирование по полю\n";
  960. cin >> q;
  961. if (q == '1')
  962. {
  963. w = 0;
  964. t = 0;
  965. cout << "Введите номер элемента\n";
  966. cin >> w;
  967. for (temp = l; temp != NULL; temp = temp->next)
  968. {
  969. t++;
  970. }
  971. if (w > t)
  972. {
  973. cout << "Введено большое число";
  974. system("pause");
  975. return;
  976. }
  977. t = 0;
  978. for (temp = l; temp != NULL; temp = temp->next)
  979. {
  980. t++;
  981. if (t == w)
  982. {
  983. zapas->inf.surn = temp->inf.surn;
  984. zapas->inf.name = temp->inf.name;
  985. zapas->inf.ot = temp->inf.ot;
  986. zapas->inf.day = temp->inf.day;
  987. zapas->inf.month = temp->inf.month;
  988. zapas->inf.year = temp->inf.year;
  989. zapas->inf.pol = temp->inf.pol;
  990. zapas->inf.ad.street = temp->inf.ad.street;
  991. zapas->inf.ad.home = temp->inf.ad.home;
  992. zapas->inf.ad.flate = temp->inf.ad.flate;
  993. cout << "Введите данные о пользователе\n ";
  994. cout << "Введите фамилию\n";
  995. cin >> temp->inf.surn;
  996. cout << "Введите имя\n";
  997. cin >> temp->inf.name;
  998. cout << "Введите отчество\n";
  999. cin >> temp->inf.ot;
  1000. cout << "Введите день рождения\n";
  1001. cin >> temp->inf.day;
  1002. if (temp->inf.day > 31 || temp->inf.day < 1)
  1003. {
  1004. cout << "\nТакого числа не существует\n";
  1005. system("pause");
  1006. temp->inf.surn = zapas->inf.surn;
  1007. temp->inf.name = zapas->inf.name;
  1008. temp->inf.ot = zapas->inf.ot;
  1009. temp->inf.day = zapas->inf.day;
  1010. temp->inf.month = zapas->inf.month;
  1011. temp->inf.year = zapas->inf.year;
  1012. temp->inf.pol = zapas->inf.pol;
  1013. temp->inf.ad.street = zapas->inf.ad.street;
  1014. temp->inf.ad.home = zapas->inf.ad.home;
  1015. temp->inf.ad.flate = zapas->inf.ad.flate;
  1016. return;
  1017. }
  1018. cout << "Введите месяц рождения\n";
  1019. cin >> temp->inf.month;
  1020. if (temp->inf.month > 12 || temp->inf.day < 1)
  1021. {
  1022. cout << "Введено неверное число\n";
  1023. system("pause");
  1024. temp->inf.surn = zapas->inf.surn;
  1025. temp->inf.name = zapas->inf.name;
  1026. temp->inf.ot = zapas->inf.ot;
  1027. temp->inf.day = zapas->inf.day;
  1028. temp->inf.month = zapas->inf.month;
  1029. temp->inf.year = zapas->inf.year;
  1030. temp->inf.pol = zapas->inf.pol;
  1031. temp->inf.ad.street = zapas->inf.ad.street;
  1032. temp->inf.ad.home = zapas->inf.ad.home;
  1033. temp->inf.ad.flate = zapas->inf.ad.flate;
  1034. return;
  1035. }
  1036. if (temp->inf.month == 2 && temp->inf.day > 29)
  1037. {
  1038. cout << "\nВ феврале на может быть больше 29 дней\n";
  1039. system("pause");
  1040. temp->inf.surn = zapas->inf.surn;
  1041. temp->inf.name = zapas->inf.name;
  1042. temp->inf.ot = zapas->inf.ot;
  1043. temp->inf.day = zapas->inf.day;
  1044. temp->inf.month = zapas->inf.month;
  1045. temp->inf.year = zapas->inf.year;
  1046. temp->inf.pol = zapas->inf.pol;
  1047. temp->inf.ad.street = zapas->inf.ad.street;
  1048. temp->inf.ad.home = zapas->inf.ad.home;
  1049. temp->inf.ad.flate = zapas->inf.ad.flate;
  1050. return;
  1051. }
  1052. else
  1053. {
  1054. if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
  1055. {
  1056. cout << "\nТакой даты не сущетсвует\n";
  1057. system("pause");
  1058. temp->inf.surn = zapas->inf.surn;
  1059. temp->inf.name = zapas->inf.name;
  1060. temp->inf.ot = zapas->inf.ot;
  1061. temp->inf.day = zapas->inf.day;
  1062. temp->inf.month = zapas->inf.month;
  1063. temp->inf.year = zapas->inf.year;
  1064. temp->inf.pol = zapas->inf.pol;
  1065. temp->inf.ad.street = zapas->inf.ad.street;
  1066. temp->inf.ad.home = zapas->inf.ad.home;
  1067. temp->inf.ad.flate = zapas->inf.ad.flate;
  1068. return;
  1069. }
  1070. }
  1071. cout << "\nВведите год рождения\n";
  1072. cin >> temp->inf.year;
  1073. if (temp->inf.year < 1950 || temp->inf.year>5000)
  1074. {
  1075. cout << "\nВведен неверный год\n";
  1076. system("pause");
  1077. temp->inf.surn = zapas->inf.surn;
  1078. temp->inf.name = zapas->inf.name;
  1079. temp->inf.ot = zapas->inf.ot;
  1080. temp->inf.day = zapas->inf.day;
  1081. temp->inf.month = zapas->inf.month;
  1082. temp->inf.year = zapas->inf.year;
  1083. temp->inf.pol = zapas->inf.pol;
  1084. temp->inf.ad.street = zapas->inf.ad.street;
  1085. temp->inf.ad.home = zapas->inf.ad.home;
  1086. temp->inf.ad.flate = zapas->inf.ad.flate;
  1087. return;
  1088. }
  1089. if (temp->inf.month == 2 && temp->inf.year % 4 != 0 && temp->inf.day == 29)
  1090. {
  1091. cout << "Увы, это не високосный год\n";
  1092. system("pause");
  1093. temp->inf.surn = zapas->inf.surn;
  1094. temp->inf.name = zapas->inf.name;
  1095. temp->inf.ot = zapas->inf.ot;
  1096. temp->inf.day = zapas->inf.day;
  1097. temp->inf.month = zapas->inf.month;
  1098. temp->inf.year = zapas->inf.year;
  1099. temp->inf.pol = zapas->inf.pol;
  1100. temp->inf.ad.street = zapas->inf.ad.street;
  1101. temp->inf.ad.home = zapas->inf.ad.home;
  1102. temp->inf.ad.flate = zapas->inf.ad.flate;
  1103. return;
  1104. }
  1105. cout << "\nВведите пол\n";
  1106. cout << "Подсказка:(w/m)\n";
  1107. cin >> temp->inf.pol;
  1108. if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
  1109. {
  1110. cout << "\nВы ввели не верный символ\n";
  1111. system("pause");
  1112. temp->inf.surn = zapas->inf.surn;
  1113. temp->inf.name = zapas->inf.name;
  1114. temp->inf.ot = zapas->inf.ot;
  1115. temp->inf.day = zapas->inf.day;
  1116. temp->inf.month = zapas->inf.month;
  1117. temp->inf.year = zapas->inf.year;
  1118. temp->inf.pol = zapas->inf.pol;
  1119. temp->inf.ad.street = zapas->inf.ad.street;
  1120. temp->inf.ad.home = zapas->inf.ad.home;
  1121. temp->inf.ad.flate = zapas->inf.ad.flate;
  1122. return;
  1123. }
  1124. cout << "\nВведите улицу\n";
  1125. cin >> temp->inf.ad.street;
  1126. cout << "\nВведите номер дома\n" << endl;
  1127. cin >> temp->inf.ad.home;
  1128. if (temp->inf.ad.home < 1)
  1129. {
  1130. cout << "\nВы ввели не верное число\n";
  1131. system("pause");
  1132. temp->inf.surn = zapas->inf.surn;
  1133. temp->inf.name = zapas->inf.name;
  1134. temp->inf.ot = zapas->inf.ot;
  1135. temp->inf.day = zapas->inf.day;
  1136. temp->inf.month = zapas->inf.month;
  1137. temp->inf.year = zapas->inf.year;
  1138. temp->inf.pol = zapas->inf.pol;
  1139. temp->inf.ad.street = zapas->inf.ad.street;
  1140. temp->inf.ad.home = zapas->inf.ad.home;
  1141. temp->inf.ad.flate = zapas->inf.ad.flate;
  1142. return;
  1143. }
  1144. cout << "\nВведите номер квартиры\n";
  1145. cin >> temp->inf.ad.flate;
  1146. if (temp->inf.ad.flate < 1)
  1147. {
  1148. cout << "\nВы ввели не верное число\n";
  1149. system("pause");
  1150. temp->inf.surn = zapas->inf.surn;
  1151. temp->inf.name = zapas->inf.name;
  1152. temp->inf.ot = zapas->inf.ot;
  1153. temp->inf.day = zapas->inf.day;
  1154. temp->inf.month = zapas->inf.month;
  1155. temp->inf.year = zapas->inf.year;
  1156. temp->inf.pol = zapas->inf.pol;
  1157. temp->inf.ad.street = zapas->inf.ad.street;
  1158. temp->inf.ad.home = zapas->inf.ad.home;
  1159. temp->inf.ad.flate = zapas->inf.ad.flate;
  1160. return;
  1161. }
  1162. cout << "Данные отредактированы\n";
  1163. system("pause");
  1164. }
  1165. }
  1166.  
  1167. }
  1168. if (q == '2')
  1169. {
  1170. cout << "\nВведите номер поля, по которому надо сделать редактирование\n";
  1171. cout << "1.Фамилия " << endl;
  1172. cout << "2.Имя " << endl;
  1173. cout << "3.Отчество " << endl;
  1174. cout << "4.День рождения " << endl;
  1175. cout << "5.Месяц рождения " << endl;
  1176. cout << "6.Год рождения " << endl;
  1177. cout << "7.Пол " << endl;
  1178. cout << "8.Адрес " << endl;
  1179. cin >> q1;
  1180. if (q1 != '8')
  1181. {
  1182. if (q1 == '1')
  1183. {
  1184. cout << "\nВведите фамилию,которую надо заменить\n";
  1185. cin >> str1;
  1186. for (temp = l; temp != NULL; temp = temp->next)
  1187. {
  1188. if (str1 == temp->inf.surn)
  1189. {
  1190. cout << "\nНайден пользователь с данной фамилией\n";
  1191. redak2(temp,zapas);
  1192. }
  1193. }
  1194. }
  1195. if (q1 == '2')
  1196. {
  1197. cout << "\nВведите имя,которое надо заменить\n";
  1198. cin >> str1;
  1199. for (temp = l; temp != NULL; temp = temp->next)
  1200. {
  1201. if (str1 == temp->inf.name)
  1202. {
  1203. cout << "\nНайден пользователь с данным именем\n";
  1204. redak2(temp, zapas);
  1205. }
  1206. }
  1207. }
  1208. if (q1 == '3')
  1209. {
  1210. cout << "\nВведите отчество,которое надо заменить\n";
  1211. cin >> str1;
  1212. for (temp = l; temp != NULL; temp = temp->next)
  1213. {
  1214. if (str1 == temp->inf.ot)
  1215. {
  1216. cout << "\nНайден пользователь с данным отчеством\n";
  1217. redak2(temp, zapas);
  1218. }
  1219. }
  1220. }
  1221. }
  1222. }
  1223. else
  1224. {
  1225. cout << "\nВведен неверный символ\n";
  1226. system("pause");
  1227. return;
  1228. }
  1229. }
  1230. /*
  1231. void myfunc(list *l,list *r)
  1232. {
  1233. int k,i,n,j;
  1234. list *temp, *l2,*r2;
  1235. string *mas,*a;
  1236. int *imas;
  1237. string str,str1;
  1238. if (l == NULL)
  1239. {
  1240. cout << "\nСписок пуст\n";
  1241. }
  1242. for
  1243. }*/
  1244. /* int k,i,n,j;
  1245. int imas;*/
  1246. /* while (1)
  1247. {
  1248. while (str == a[i] && i < k + 1)
  1249. {
  1250. i++; k++;
  1251. }
  1252. if (i - 1 < k)
  1253. {
  1254. str =a[i]
  1255. }
  1256. }*/
  1257. void saveinfiletxt(list *temp)
  1258. {
  1259. list *t;
  1260. t = temp;
  1261. ofstream f("1.txt",ios::out);
  1262. if (!f)
  1263. {
  1264. cout << "\nНевозможно открыть файл\n";
  1265. system("pause");
  1266. return;
  1267. }
  1268. while (t != NULL)
  1269. {
  1270. f << t->inf.surn<<"\n";
  1271. f << t->inf.name<< "\n";
  1272. f << t->inf.ot << "\n";
  1273. f << t->inf.day << "\n";
  1274. f << t->inf.month << "\n";
  1275. f << t->inf.year << "\n";
  1276. f << t->inf.pol << "\n";
  1277. f << t->inf.ad.street << "\n";
  1278. f << t->inf.ad.home << "\n";
  1279. f << t->inf.ad.flate << "\n";
  1280. t = t->next;
  1281. }
  1282. cout << "Сохранение в текстовый файл выполнено\n";
  1283. system("pause");
  1284. f.close();
  1285. }
  1286. void readoutfiletxt(list *l)
  1287. {
  1288. ifstream fin("1.txt",ios::in);
  1289. list *temp;
  1290. string str;
  1291. int d;
  1292. d = 0;
  1293. if(!fin)
  1294. {
  1295. cout << "\nФайл нельзя открыть\n";
  1296. system("pause");
  1297. return;
  1298. }
  1299. l = new list;
  1300. temp = l;
  1301. fin.seekg(0, ios::beg);
  1302. while (!EOF)
  1303. {
  1304. getline(fin, temp->inf.surn);
  1305. getline(fin, temp->inf.name);
  1306. getline(fin, temp->inf.ot);
  1307. /* getline(fin, temp->inf.day);
  1308. getline(fin, temp->inf.month);
  1309. getline(fin, temp->inf.year);
  1310. getline(fin, temp->inf.pol);
  1311. getline(fin, temp->inf.ad.street);
  1312. getline(fin, temp->inf.ad.home);
  1313. getline(fin, temp->inf.ad.flate);
  1314. d++;
  1315. */
  1316. // temp->
  1317. }
  1318. cout << temp->inf.surn<<" fam"<<endl;
  1319. cout << temp->inf.name <<" nam"<< endl;
  1320. cout << temp->inf.ot << "double nam"<<endl;
  1321. cout << temp->inf.day << " lf"<<endl;
  1322. cout << temp->inf.month << endl;
  1323. /* cout << temp->inf.year << endl;
  1324. cout << temp->inf.pol << endl;
  1325. cout << temp->inf.ad.street << endl;
  1326. cout << temp->inf.ad.home << endl;
  1327. cout << temp->inf.ad.flate << endl;*/
  1328. system("pause");
  1329. }
  1330. void saveinbinarfile(list *tem)
  1331. {
  1332. ofstream out("2.txt", ios::out, ios::binary);
  1333. if (!out)
  1334. {
  1335. cout << "Файл не удалось открыть";
  1336. system("pause");
  1337. return;
  1338. }
  1339. list *t;
  1340. t = tem;
  1341. while (t != NULL)
  1342. {
  1343. out.write((char*)&t->inf, sizeof(t->inf));
  1344. t = t->next;
  1345. }
  1346. out.close();
  1347. return;
  1348. }/*
  1349. list* readoutbinarfile(list* l,list* r)
  1350. {
  1351. int d;
  1352. d = 0;
  1353. list* t,*t1;
  1354. if (l == NULL)
  1355. {
  1356. t = l;
  1357. }
  1358. ifstream in("2.txt",ios::in ,ios::binary);
  1359. while (in)
  1360. {
  1361. d++;
  1362. t = new list;
  1363. in.read((char*)&t->inf, sizeof(t->inf));
  1364. cout << "ttt" << endl;
  1365. if (d == 1)
  1366. {
  1367. l = t;
  1368. t1 = l;
  1369. r = t;
  1370. }
  1371. else
  1372. {
  1373. t->pre = r;
  1374. r->next = t;
  1375. r = t;
  1376. }
  1377. };
  1378. in.close();
  1379. return l;
  1380. }
  1381. */
  1382. void sort(list* l, list* r)
  1383. {
  1384. list* temp1, *temp2;
  1385. for (temp1 = l; temp1; temp1 = temp1->next)
  1386. for (temp2 = temp1; temp2; temp2 = temp2->next)
  1387. if (temp1->inf.ad.street > temp2->inf.ad.street)
  1388. swap(temp1->inf, temp2->inf);
  1389. }
  1390.  
  1391. int main()
  1392. {
  1393. setlocale(LC_ALL, "rus");
  1394. list *l, *r,*t,*td;
  1395. string namefile;
  1396. int pois,value;
  1397. wint_t c;
  1398. char c2, c21,c3,c0;
  1399. int k;
  1400. SendMessage(GetConsoleWindow(), WM_SYSKEYDOWN, VK_RETURN, 0x20000000);
  1401. l = NULL;
  1402. r = NULL;
  1403. // system("cls");
  1404. while(1)
  1405. {
  1406. system("color 80");
  1407. SetColor(15, 8);
  1408. cout << "========================================================================================================================================================================" << endl;
  1409. cout << setw(2950) << "1 Добавить элемент ";
  1410. SetColor(8, 8);
  1411. cout<< setw(74) << "|" << endl;
  1412. SetColor(15, 8);
  1413. cout << setw(86) << "2 Просмотр ";
  1414. SetColor(8, 8);
  1415. cout<<setw(82)<<"|"<< endl;
  1416. SetColor(15, 8);
  1417. cout << setw(94) << "3 Популярные улицы ";
  1418. SetColor(8, 8);
  1419. cout << setw(74) << "|" << endl;
  1420. SetColor(15, 8);
  1421. cout << setw(79) << "4 ";
  1422. SetColor(8, 8);
  1423. cout << setw(89) << "|" << endl;
  1424. SetColor(15, 8);
  1425. cout << setw(83) << "5 Поиск ";
  1426. SetColor(8, 8);
  1427. cout<<setw(85)<<"|"<< endl;
  1428. SetColor(15, 8);
  1429. cout << setw(92) << "6 Редактирование ";
  1430. SetColor(8, 8);
  1431. cout<< setw(76)<<"|"<< endl;
  1432. SetColor(15, 8);
  1433. cout << setw(82) << "7 Файл ";
  1434. SetColor(8, 8);
  1435. cout<< setw(86)<<"|"<< endl;
  1436. SetColor(15, 8);
  1437. cout << setw(86) << "8 Удаление ";
  1438. SetColor(8, 8);
  1439. cout << setw(82) << "|" << endl;
  1440. SetColor(15, 8);
  1441. cout << setw(83) << "9 Выход ";
  1442. SetColor(8, 8);
  1443. cout << setw(85) << "|" << endl;
  1444. SetColor(15, 8);
  1445. cout << setw(3360)<<"========================================================================================================================================================================" << endl;
  1446. // c = cin.get();
  1447. // cin >> c;
  1448. c = _getwch();
  1449. switch (c)
  1450. {
  1451. case '1':
  1452. if (l == NULL)
  1453. {
  1454. system("cls");
  1455. l = create();
  1456. r = l;
  1457. }
  1458. else
  1459. {
  1460. if (l->next == NULL)
  1461. {
  1462. system("cls");
  1463. r = dob_second(l);
  1464. if (l != r)
  1465. {
  1466. l->next = r;
  1467. r->pre = l;
  1468. r->next = NULL;
  1469. }
  1470. }
  1471. else
  1472. {
  1473. system("cls");
  1474. r = add(r);
  1475. }
  1476. }
  1477. break;
  1478. case '2':
  1479. system("CLS");
  1480. cout << "Выберите номер желаемого просмотра\n";
  1481. cout << "1 Просмотр таблицей\n";
  1482. cout << "2 Обычный просмотр\n";
  1483. cin >> c0;
  1484. if (c0 == '1')
  1485. {
  1486. system("CLS");
  1487. // SetColor(0, 15);
  1488. tabl_show(l, r);
  1489. }
  1490. if (c0 == '2')
  1491. {
  1492. system("CLS");
  1493. show(l, r);
  1494. system("pause");
  1495. }
  1496. break;
  1497. case '3':
  1498. sort(l,r);
  1499. myfunc(l, r);
  1500. break;
  1501. case '4':
  1502. // myfunc(l,r);
  1503. break;
  1504. case '5':
  1505. cout << "\nВведите номер поля, по которому будет происходить поиск\n";
  1506. cout << "1.Фамилия " << endl;
  1507. cout << "2.Имя " << endl;
  1508. cout << "3.Отчество " << endl;
  1509. cout << "4.День рождения " << endl;
  1510. cout << "5.Месяц рождения " << endl;
  1511. cout << "6.Год рождения " << endl;
  1512. cout << "7.Пол " << endl;
  1513. cout << "8.Адрес " << endl;
  1514. cin >> c2;
  1515. if (c2 != '8')
  1516. {
  1517. search(l, r, c2);
  1518. }
  1519. else
  1520. {
  1521. cout << "Выберите номер поля адреса\n";
  1522. cout << " 1.Улица" << endl;
  1523. cout << " 2.Дом" << endl;
  1524. cout << " 3.Квартира" << endl;
  1525. cin >> c21;
  1526. int y = c21+c2;
  1527. search(l, r, y);
  1528. system("pause");
  1529. }
  1530. break;
  1531. case '6':
  1532. redakt(l,r);
  1533. break;
  1534. case '7':
  1535. system("CLS");
  1536. cout << "1 Чтение с тесктового файла\n";
  1537. cout << "2 Сохранение в текстовый файл\n";
  1538. cout << "3 Чтение с типизированного файла\n";
  1539. cout << "4 Сохраниние в типизированный файл\n";
  1540. cin >> c3;
  1541. if (c3 == '1')
  1542. {
  1543. cout << "1\n";
  1544. readoutfiletxt(l);
  1545. }
  1546. if (c3 == '2')
  1547. {
  1548. cout << "2\n";
  1549. saveinfiletxt(l);
  1550. }
  1551. if (c3 == '3')
  1552. {
  1553. l=readoutbinarfile(l,r);
  1554. }
  1555. if (c3 == '4')
  1556. {
  1557. saveinbinarfile(l);
  1558. }
  1559. break;
  1560. case '8':
  1561. cout << "\nВведите номер элемента для удаления\n";
  1562. cin >> value;
  1563. if (value == 1)
  1564. {
  1565. l=del_first(l, r);
  1566. }
  1567. else
  1568. {
  1569. k = 0;
  1570. for (t = l; t != NULL; t = t->next)
  1571. {
  1572. k++;
  1573. }
  1574. if (value <= k)
  1575. {
  1576. if (value < k)
  1577. {
  1578. k = 0;
  1579. td = l;
  1580. for (t = l; t != NULL; t = t->next)
  1581. {
  1582. k++;
  1583. if (k == value)
  1584. {
  1585. t->pre->next = t->next;
  1586. t->next->pre = t->pre;
  1587. }
  1588. }
  1589. delete t;
  1590. }
  1591. if (value == k)
  1592. {
  1593. r = del_last(r);
  1594. }
  1595. }
  1596. else
  1597. {
  1598. cout << "\nБыло введено большое число\n";
  1599. system("pause");
  1600. }
  1601. }
  1602. break;
  1603. case 27:
  1604. if(IDOK== MessageBox(NULL, L"Вы действительно хотите выйти?", L"Account Details", MB_OKCANCEL | MB_ICONQUESTION | MB_SETFOREGROUND))
  1605. return 0;
  1606. }
  1607. };
  1608. return 0;
  1609. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement