Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.13 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <filesystem>
  8.  
  9. using namespace std;
  10.  
  11. namespace fs = std::experimental::filesystem;
  12.  
  13. struct Proekts
  14. {
  15. string nameproject;
  16. int costproject;
  17. };
  18.  
  19. struct Kyrsi
  20. {
  21. int students;
  22.  
  23. int costofeducation;
  24.  
  25. int nomer;
  26.  
  27. };
  28.  
  29. class unit
  30. {
  31. protected:
  32. string name; //подразделение название
  33. string fio; //подразделение название руководителя (ФИО),
  34. int graduate, employee; // число аспирантов, число сотрудников
  35.  
  36. public:
  37. unit() {}
  38. string getname() { return name; }
  39. string getfio() { return fio; }
  40. int getgraduate() { return graduate; }
  41. int getemployee() { return employee; }
  42. virtual void print() = 0;
  43. virtual int profit() = 0;
  44. virtual void zapic(string a, ofstream& n) = 0;
  45. virtual void otkrit(string a, ifstream& n) = 0;
  46.  
  47. };
  48.  
  49. class educational : public unit
  50. {
  51.  
  52. private: //проекты(название, стоимость)
  53. int kolproject;
  54. vector <Proekts> proekti;
  55. public:
  56. educational()
  57. {
  58. cout << endl << "Vvedite nazvanei podrazdelenia ";
  59. cin >> name;
  60. cout << endl << "Vvedite FIO rykovoditelia ";
  61. cin >> fio;
  62. cout << endl << "Chislo aspirantov podrazdelenia ";
  63. cin >> graduate;
  64. cout << endl << "Chislo sotrydnikov podrazdelenia ";
  65. cin >> employee;
  66. cout << endl << "Kolichestvo proektov ";
  67. cin >> kolproject;
  68. proekti.reserve(kolproject);
  69. for (int i = 0; i < kolproject; i++)
  70. {
  71. Proekts tosha;
  72.  
  73. cout << endl << "Nazvanie proekta ";
  74. cin >> tosha.nameproject;
  75. cout << endl << "Stoimost proekta ";
  76. cin >> tosha.costproject;
  77. cin.get();
  78. proekti.push_back(tosha);
  79. }
  80. }
  81. educational(int f)
  82. {}
  83. void print()
  84. {
  85. cout << endl << "Nazvanei podrazdelenia ";
  86. cout << name;
  87. cout << endl << "FIO rykovoditelia ";
  88. cout << fio;
  89. cout << endl << "Chislo aspirantov podrazdelenia ";
  90. cout << graduate;
  91. cout << endl << "Chislo sotrydnikov podrazdelenia ";
  92. cout << employee;
  93. cout << endl << "Kolichestvo proektov ";
  94. cout << kolproject;
  95. for (int i = 0; i < kolproject; i++)
  96. {
  97. cout << endl << "Nazvanie proekta ";
  98. cout << proekti[i].nameproject;
  99. cout << endl << "Stoimost proekta ";
  100. cout << proekti[i].costproject;
  101.  
  102. }
  103. cout << endl;
  104. }
  105. int profit()
  106.  
  107. {
  108. int otvet = 0;
  109. for (int i = 0; i < kolproject; i++)
  110. {
  111. otvet = otvet + proekti[i].costproject;
  112. }
  113. return otvet;
  114. }
  115. void zapic(string a, ofstream& pot)
  116. {
  117. pot << 1;
  118. pot << "\n";
  119. pot << name;
  120. pot << "\n";
  121. pot << fio;
  122. pot << "\n";
  123. pot << graduate;
  124. pot << "\n";
  125. pot << employee;
  126. pot << "\n";
  127. pot << kolproject;
  128. pot << "\n";
  129. for (int i = 0; i < kolproject; i++)
  130. {
  131. pot << proekti[i].nameproject;
  132. pot << "\n";
  133. pot << proekti[i].costproject;
  134. pot << "\n";
  135.  
  136. }
  137. }
  138. void otkrit(string a, ifstream& pot)
  139. {
  140.  
  141. cout << endl << "Nazvanei podrazdelenia ";
  142. pot >> name;
  143. cout << name;
  144. cout << endl << "FIO rykovoditelia ";
  145. pot >> fio;
  146. cout << fio;
  147. cout << endl << "Chislo aspirantov podrazdelenia ";
  148. pot >> graduate;
  149. cout << graduate;
  150. cout << endl << "Chislo sotrydnikov podrazdelenia ";
  151. pot >> employee;
  152. cout << employee;
  153. cout << endl << "Kolichestvo proektov ";
  154. pot >> kolproject;
  155. cout << kolproject;
  156. proekti.reserve(kolproject);
  157. for (int i = 0; i < kolproject; i++)
  158. {
  159. Proekts tosha;
  160. cout << endl << "Nazvanie proekta ";
  161. pot >> tosha.nameproject;
  162. cout << tosha.nameproject;
  163. cout << endl << "Stoimost proekta ";
  164. pot >> tosha.costproject;
  165. cout << tosha.costproject;
  166. proekti.push_back(tosha);
  167.  
  168. }
  169. cout << endl;
  170.  
  171. }
  172.  
  173. };
  174.  
  175. class science : public unit
  176. {
  177.  
  178. private:
  179. vector <Kyrsi> kyrsis[6]; //число студентов и стоимость обучения одного студента , курс
  180. int sc = 0;
  181. public:
  182. science() :
  183. unit()
  184. {
  185. cout << endl << "Vvedite nazvanei podrazdelenia ";
  186. cin >> name;
  187. cout << endl << "Vvedite FIO rykovoditelia ";
  188. cin >> fio;
  189. cout << endl << "Chislo aspirantov podrazdelenia ";
  190. cin >> graduate;
  191. cout << endl << "Chislo sotrydnikov podrazdelenia ";
  192. cin >> employee;
  193. string flag;
  194. do
  195. {
  196. Kyrsi tosha;
  197. cout << endl << "Kakoe kyrs? ";
  198. cin >> tosha.nomer;
  199. tosha.students = 1;
  200. cout << endl << "Stoimost obychenia stydenta ";
  201. cin >> tosha.costofeducation;
  202. cin.get();
  203. kyrsis[tosha.nomer-1].push_back(tosha);
  204. sc++;
  205. cout << endl << "Prodolgit? (yes/no)" << endl;
  206. cin >> flag;
  207. } while (flag != "no");
  208.  
  209. }
  210. science(int y)
  211. {}
  212. void print()
  213. {
  214. cout << endl << "Nazvanei podrazdelenia ";
  215. cout << name;
  216. cout << endl << "FIO rykovoditelia ";
  217. cout << fio;
  218. cout << endl << "Chislo aspirantov podrazdelenia ";
  219. cout << graduate;
  220. cout << endl << "Chislo sotrydnikov podrazdelenia ";
  221. cout << employee;
  222. for (int i = 0; i < 6; i++)
  223. {
  224. for (int j = 0; j < kyrsis[i].size(); j++)
  225. {
  226. cout << endl << "Kolichestvo ctydentov " << i + 1 << " kyrsa ";
  227. cout << kyrsis[i][j].students;
  228. cout << endl << "Stoimost obychenia stydenta " << i + 1 << " kyrsa ";
  229. cout << kyrsis[i][j].costofeducation;
  230. }
  231. }
  232. cout << endl;
  233. }
  234. int profit()
  235. {
  236. int otvet = 0;
  237. for (int i = 0; i < 6; i++)
  238. for (int j = 0; j< kyrsis[i].size();j++)
  239. otvet = otvet + kyrsis[i][j].students * kyrsis[i][j].costofeducation;
  240. return otvet;
  241. }
  242. void zapic(string a, ofstream& pot)
  243. {
  244. pot << 2;
  245. pot << "\n";
  246. pot << name;
  247. pot << "\n";
  248. pot << fio;
  249. pot << "\n";
  250. pot << graduate;
  251. pot << "\n";
  252. pot << employee;
  253. pot << '\n';
  254. pot << sc << '\n';
  255. for (int i = 0; i < 6; i++)
  256. {
  257. if (kyrsis[i].size()!=0)
  258. for (int j = 0; j < kyrsis[i].size(); j++)
  259. {
  260. pot << i + 1 << '\n';
  261. pot << kyrsis[i][j].costofeducation << '\n';
  262. }
  263. }
  264. }
  265. void otkrit(string a, ifstream& pot)
  266. {
  267. string str;
  268. cout << endl << "Nazvanei podrazdelenia ";
  269. pot >> name;
  270. cout << name;
  271. cout << endl << "FIO rykovoditelia ";
  272. pot >> fio;
  273. cout << fio;
  274. cout << endl << "Chislo aspirantov podrazdelenia ";
  275. pot >> graduate;
  276. cout << graduate;
  277. cout << endl << "Chislo sotrydnikov podrazdelenia ";
  278. pot >> employee;
  279. cout << employee;
  280. pot >> sc;
  281. for (int i = 0; i < sc;i++)
  282. {
  283. Kyrsi tosha;
  284. int n;
  285.  
  286. pot >> n;
  287. cout << endl << "Odin stydent ";
  288. cout << endl << "Nomer kyrsa " << n ;
  289.  
  290. //kyrsis[n-1].resize(1);
  291. pot >> tosha.costofeducation;
  292. cout << endl << "Stoimost obychenia " << tosha.costofeducation;
  293. tosha.nomer = n;
  294. tosha.students = 1;
  295. kyrsis[n-1].push_back(tosha);
  296.  
  297. }
  298. cout << endl;
  299. }
  300. };
  301.  
  302.  
  303. bool p1(unit* a, unit* l)
  304. {
  305. return a->getname() > l->getname();
  306. }
  307.  
  308. bool p2(unit* a, unit* l)
  309. {
  310.  
  311. return a->getemployee() > l->getemployee();
  312.  
  313. }
  314.  
  315. class BD
  316. {
  317. public: vector <unit*> baza;
  318. void zapolnenie()
  319. {
  320. string flag; string vibor;
  321. do
  322. {
  323. cout << endl << "Kakoe predpriatie? 1) obrazovatelnoe (o) ; 2) nauchnoe (n) ";
  324. cin >> vibor;
  325. if (vibor == "o")
  326. {
  327. baza.push_back(new educational);
  328. }
  329. if (vibor == "n")
  330. {
  331. baza.push_back(new science);
  332. }
  333. if (vibor != "n" && vibor != "o") {
  334. cout << endl << "Nepravilni vvod\n" << endl;
  335. }
  336. cout << endl << "Prodolgit? (yes/no)" << endl;
  337. cin >> flag;
  338.  
  339. } while (flag != "no");
  340. }
  341. void sortirovka1()
  342.  
  343. {
  344. sort(baza.begin(), baza.end(), p1);
  345.  
  346. for (int i = 0; i < baza.size(); i++)
  347. {
  348. baza[i]->print();
  349. }
  350. }
  351. void sortirovka2()
  352. {
  353. sort(baza.begin(), baza.end(), p2);
  354.  
  355. for (int i = 0; i < baza.size(); i++)
  356. {
  357. baza[i]->print();
  358. }
  359.  
  360. }
  361. void profit()
  362. {
  363. for (int i = 0; i < baza.size(); i++)
  364. {
  365. cout << endl << "Viruchka= ";
  366. cout << baza[i]->profit();
  367. }
  368. cout << endl;
  369. }
  370. void nach()
  371. {
  372. bool flag2 = 1;
  373. string a;
  374. cout << endl << "Vvedite FIO ";
  375. cin >> a;
  376. for (int i = 0; i < baza.size(); i++)
  377. {
  378. if (baza[i]->getfio() == a)
  379. {
  380. baza[i]->print();
  381. flag2 = 0;
  382. }
  383. else
  384. {
  385. baza.erase(baza.cbegin() + i);
  386. i--;
  387. flag2 = 0;
  388. }
  389. }
  390. if (flag2)
  391. {
  392. cout << endl << "Net takogo " << endl;
  393. }
  394. }
  395. void aspir()
  396. {
  397. bool flag2 = 1;
  398. int a;
  399. cout << endl << "Vvedite kolichestvo aspirantov ";
  400. cin >> a;
  401. for (int i = 0; i < baza.size(); i++)
  402. {
  403. if ((baza[i]->getemployee() / baza[i]->getgraduate()) < a || (baza[i]->getemployee() / baza[i]->getgraduate()) == a)
  404. {
  405. baza[i]->print();
  406. flag2 = 0;
  407. }
  408. if ((baza[i]->getemployee() / baza[i]->getgraduate()) > a )
  409. {
  410. baza.erase(baza.cbegin() + i);
  411. i--;
  412. flag2 = 0;
  413. }
  414.  
  415. }
  416. if (flag2)
  417. {
  418. cout << endl << "Net takogo " << endl;
  419. }
  420. }
  421. void fail(string h)
  422. {
  423. string b = "C:\\Users\\Crazzy\\Desktop\\BDfail\\";
  424. b = b + h + ".txt";
  425.  
  426. ofstream rewrite(b);
  427. rewrite.write("", 0);
  428. rewrite.close();
  429.  
  430. int vel = baza.size();
  431. ofstream pot;
  432. pot.open(b, ofstream::app);
  433. pot << vel;
  434. pot << "\n";
  435.  
  436. for (int i = 0; i < baza.size(); i++)
  437. {
  438. baza[i]->zapic(b, pot);
  439. }
  440. pot.close();
  441. }
  442. void fail()
  443. {
  444. string h;
  445. string b = "C:\\Users\\Crazzy\\Desktop\\BDfail\\";
  446. cout << "Vvedite nazvanio faila " << endl;
  447. cin >> h;
  448. b = b + h + ".txt";
  449. ofstream rewrite(b);
  450. rewrite.write("", 0);
  451. rewrite.close();
  452.  
  453. int vel = baza.size();
  454. ofstream pot;
  455. pot.open(b, ofstream::app);
  456. pot << vel;
  457. pot << "\n"; //один раз открыть , один закрыть
  458.  
  459. for (int i = 0; i < baza.size(); i++)
  460. {
  461. baza[i]->zapic(b, pot);
  462. }
  463. pot.close();
  464. }
  465. void udal()
  466. {
  467.  
  468. bool flag2 = 1;
  469. string a;
  470. cout << endl << "Vvedite nazvanio podrazdelenia ";
  471. cin >> a;
  472. auto iter = baza.cbegin(); // указатель на первый элемент
  473. for (int i = 0; i < baza.size(); i++)
  474. {
  475. if (baza[i]->getname() == a)
  476. {
  477. baza.erase(iter + i);
  478. flag2 = 0;
  479. break;
  480. }
  481. }
  482. if (flag2)
  483. {
  484. cout << endl << "Net takogo " << endl;
  485. }
  486.  
  487. for (int i = 0; i < baza.size(); i++)
  488. {
  489. baza[i]->print();
  490. }
  491. }
  492. void chtenie( string h)
  493. {
  494. int g1, g2 = 0;
  495.  
  496. string b;
  497. while (true)
  498. {
  499. b = "C:\\Users\\Crazzy\\Desktop\\BDfail\\";
  500. b = b + h + ".txt";
  501. ifstream g;
  502. g.open(b);
  503. try
  504. {
  505. if (!g.is_open())
  506. {
  507. throw exception("Error: Takogo BD net\n");
  508. }
  509. else { break; }
  510.  
  511. }
  512. catch (const std::exception& ex)
  513. {
  514. cout << ex.what() << endl;
  515. }
  516. }
  517. ifstream pot1;
  518. pot1.open(b);
  519. pot1 >> g1;
  520.  
  521. for (int i = 0; i < g1; i++)
  522. {
  523. pot1 >> g2;
  524.  
  525. if (g2 == 1)
  526. {
  527. baza.push_back(new educational(g2));
  528. baza[i]->otkrit(b, pot1);
  529. }
  530. else
  531. {
  532. baza.push_back(new science(g2));
  533. baza[i]->otkrit(b, pot1);
  534. }
  535.  
  536. }
  537.  
  538. pot1.close();
  539. cout << "____________________________________________________________";
  540. }
  541. void dobav(string h)
  542. {
  543.  
  544. string b = "C:\\Users\\Crazzy\\Desktop\\BDfail//";
  545.  
  546. b = b + h + ".txt";
  547. ofstream pot;
  548. pot.open(b, ofstream::app);
  549. for (int i = 0; i < baza.size(); i++)
  550. {
  551. baza[i]->zapic(b, pot);
  552. }
  553. pot.close();
  554. }
  555.  
  556. };
  557.  
  558. int main()
  559. {
  560.  
  561. string flag2;
  562. do
  563. { while (true)
  564. {
  565. cout << "__________________________________________________________" << endl;
  566. cout << "Dobro pogalovat" << endl;
  567. cout << "Spisok komand: " << endl;
  568. cout << "1) Sozdat BD " << endl;
  569. cout << "2) Otkrit BD " << endl;
  570. cout << "3) Vivod spiska BD " << endl;
  571. cout << "4) Viborka " << endl;
  572. cout << "5) Izmenit BD " << endl;
  573. cout << "6) Dopolnitelnoe " << endl << endl;
  574. string vib, n, exo;
  575. do
  576. {
  577. n = cin.get();
  578. vib = vib + n;
  579. } while (cin.peek() != '<' && cin.peek() != '\n');
  580. n = cin.get();
  581.  
  582. if ( n == "<")
  583. {
  584. int raz = vib.size();
  585. vib.erase(vib.begin() + raz - 1);
  586.  
  587. do
  588. {
  589. n = cin.get();
  590. exo = exo + n;
  591. } while (cin.peek() != '>');
  592. n = cin.get();
  593. n = cin.get();
  594. }
  595. try
  596. {
  597. if (vib != "sozdat bd" && vib != "otkrit bd" && vib != "vivod spiska bd" && vib != "viborka" && vib != "izmenit bd" && vib != "dopolnitelnoe" && vib != "sozdat bd" && vib != "otkrit bd" && vib != "vivod spiska bd" && vib != "viborka" && vib != "izmenit bd" && vib != "dopolnitelnoe")
  598. {
  599. throw exception("Error: Nepravilnii vvod\n");
  600. }
  601. }
  602. catch (const std::exception& ex)
  603. {
  604. cout << ex.what() << endl;
  605. /*cin.clear();
  606. while (cin.get() != '\n');
  607. continue; */
  608. }
  609.  
  610. if (vib == "vivod spiska bd")
  611. {
  612. for (auto& hen : fs::directory_iterator("C:\\Users\\Crazzy\\Desktop\\BDfail"))
  613. {
  614. cout << hen.path().filename() << endl;
  615. }
  616. }
  617. if (vib == "sozdat bd")
  618. {
  619. BD ann;
  620. ann.zapolnenie();
  621. string yes_no;
  622. cin.get();
  623. while (true)
  624. {
  625. cout << "Sohranit cozdannoe BD? yes/no ";
  626. try
  627. {
  628. getline(cin, yes_no);
  629. if (yes_no != "yes" && yes_no != "no")
  630. {
  631. throw exception("Error: Nepravilnii tip\n");
  632. }
  633. else { break; }
  634.  
  635. }
  636. catch (const std::exception& ex)
  637. {
  638. cout << ex.what() << endl;
  639. /*cin.clear();
  640. while (cin.get() != '\n');
  641. continue;*/
  642. }
  643. }
  644. if (yes_no == "yes")
  645. {
  646. ann.fail(exo);
  647. }
  648. }
  649.  
  650. if (vib == "izmenit bd")
  651. {
  652. string yes_no;
  653. while (true)
  654. {
  655. cout << endl << "Chto gelaete sdelat? 1) otsortirovat zapisi, (sort) 2) ydalit zapisi, (del) 3) dobavit " << endl;
  656. try
  657. {
  658. getline(cin, yes_no);
  659. if (yes_no != "sort" && yes_no != "del" && yes_no != "dobavit")
  660. {
  661. throw exception("Error: Nepravilnii vvod\n");
  662. }
  663. else { break; }
  664. }
  665. catch (const std::exception& ex)
  666. {
  667. cout << ex.what() << endl;
  668. /*cin.clear();
  669. while (cin.get() != '\n');
  670. continue;*/
  671. }
  672. }
  673. if (yes_no == "sort")
  674. {
  675. while (true)
  676. {
  677. cout << "1) po nazvaniy, 2) po chisly sotrudnikov ";
  678. try
  679. {
  680. getline(cin, yes_no);
  681. if (yes_no != "po nazvaniy" && yes_no != "po chisly sotrudnikov")
  682. {
  683. throw exception("Error: Nepravilnii vvod\n");
  684. }
  685. else { break; }
  686. }
  687. catch (const std::exception& ex)
  688. {
  689. cout << ex.what() << endl;
  690. /*cin.clear();
  691. while (cin.get() != '\n');
  692. continue;*/
  693. }
  694. }
  695. if (yes_no == "po nazvaniy")
  696. {
  697. BD ann;
  698. ann.chtenie(exo);
  699. ann.sortirovka1();
  700. string uy;
  701. while (true)
  702. {
  703. cout << endl << "Hotite sohranit? yes/no ";
  704. try
  705. {
  706. getline(cin, uy);
  707. if (uy != "yes" && uy != "no")
  708. {
  709. throw exception("Error: Nepravilnii vvod\n");
  710. }
  711. else { break; }
  712. }
  713. catch (const std::exception& ex)
  714. {
  715. cout << ex.what() << endl;
  716. /*cin.clear();
  717. while (cin.get() != '\n');
  718. continue;*/
  719. }
  720. }
  721. if (uy == "yes")
  722. {
  723. ann.fail();
  724. }
  725.  
  726. }
  727. else
  728. {
  729. BD ann;
  730. ann.chtenie(exo);
  731. ann.sortirovka2();
  732. string uy;
  733. while (true)
  734. {
  735. cout << "Hotite sohranit? yes/no ";
  736. try
  737. {
  738. getline(cin, uy);
  739. if (uy != "no" && uy != "yes")
  740. {
  741. throw exception("Error: Nepravilnii vvod\n");
  742. }
  743. else { break; }
  744. }
  745. catch (const std::exception& ex)
  746. {
  747. cout << ex.what() << endl;
  748. /*cin.clear();
  749. while (cin.get() != '\n');
  750. continue;*/
  751. }
  752. }
  753. if (uy == "yes")
  754. {
  755. ann.fail();
  756. }
  757. }
  758.  
  759. }
  760. if (yes_no == "del")
  761. {
  762. BD ann;
  763. ann.chtenie(exo);
  764. ann.udal();
  765. string uy;
  766. cin.get();
  767. while (true)
  768. {
  769. cout << "Hotite sohranit? yes/no ";
  770. try
  771. {
  772. getline(cin, uy);
  773. if (uy != "yes" && uy != "no")
  774. {
  775. throw exception("Error: Nepravilnii vvod\n");
  776. }
  777. else { break; }
  778. }
  779. catch (const std::exception& ex)
  780. {
  781. cout << ex.what() << endl;
  782. /*cin.clear();
  783. while (cin.get() != '\n');
  784. continue;*/
  785. }
  786. }
  787. if (uy == "yes")
  788. {
  789. ann.fail();
  790. }
  791.  
  792. }
  793.  
  794.  
  795. if (yes_no == "dobavit")
  796. {
  797. BD ann;
  798. ann.chtenie(exo);
  799. ann.zapolnenie();
  800. ann.dobav(exo);
  801. string rar;
  802. while (true)
  803. {
  804. cout << "Sohranit izmenenia? yes / no ";
  805. try
  806. {
  807. cin >> rar;
  808. if (rar != "no" && rar != "yes")
  809. {
  810. throw exception("Error: Nepravilnii vvod\n");
  811. }
  812. else { break; }
  813. }
  814. catch (const std::exception& ex)
  815. {
  816. cout << ex.what() << endl;
  817. /*cin.clear();
  818. while (cin.get() != '\n');
  819. continue;*/
  820. }
  821. }
  822. if (rar == "yes")
  823. {
  824. ann.fail();
  825. cin.get();
  826. }
  827. }
  828. }
  829.  
  830. if (vib == "dopolnitelnoe")
  831. {
  832. string y;
  833. while (true)
  834. {
  835. cout << endl << "1 - podschet pridili BD (pribil), 2 - poisk podrazdelenai vnytri BD po FIO (poisk po fio) " << endl;
  836. try
  837. {
  838. getline(cin, y);
  839. if (y != "pribil" && y != "poisk po fio")
  840. {
  841. throw exception("Error: Nepravilnii vvod\n");
  842. }
  843. else { break; }
  844. }
  845. catch (const std::exception& ex)
  846. {
  847. cout << ex.what() << endl;
  848. /*cin.clear();
  849. while (cin.get() != '\n');
  850. continue;*/
  851. }
  852. }
  853. {
  854. BD ann;
  855. ann.chtenie(exo);
  856.  
  857. if (y == "pribil")
  858. {
  859. ann.profit();
  860. }
  861. else
  862. {
  863. ann.nach();
  864. }
  865. }
  866. }
  867.  
  868. if (vib == "otkrit bd")
  869. {
  870. BD ann;
  871. ann.chtenie(exo);
  872. }
  873.  
  874. if (vib == "viborka")
  875. {
  876. string vin;
  877. while (true)
  878. {
  879. cout << "Kakaia viborka? 1) po aspirantam, 2) po nachalniky ";
  880. try
  881. {
  882. getline(cin, vin);
  883. if (vin != "po aspirantam" && vin != "po nachalniky")
  884. {
  885. throw exception("Error: Nepravilnii vvod\n");
  886. }
  887. else { break; }
  888. }
  889. catch (const std::exception& ex)
  890. {
  891. cout << ex.what() << endl;
  892. /*cin.clear();
  893. while (cin.get() != '\n');
  894. continue;*/
  895. }
  896. }
  897. if (vin == "po aspirantam")
  898. {
  899. BD ann;
  900. ann.chtenie(exo);
  901. ann.aspir();
  902. ann.fail();
  903. }
  904. else
  905. {
  906. BD ann;
  907. ann.chtenie(exo);
  908. ann.nach();
  909. ann.fail();
  910. }
  911. }
  912. }
  913. while (true)
  914. {
  915. cout << endl << "Prodolgit? (yes/no)" << endl;
  916. try
  917. {
  918. getline(cin, flag2);
  919. if (flag2 != "no" && flag2 != "yes")
  920. {
  921. throw exception("Error: Oshibka vvoda");
  922. }
  923. else { break; }
  924. }
  925. catch (const std::exception& ex)
  926. {
  927. cout << ex.what() << endl;
  928. /*cin.clear();
  929. while (cin.get() != '\n');
  930. continue;*/
  931. }
  932. }
  933.  
  934. } while (flag2 != "no");
  935. return 0;
  936. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement