Advertisement
Guest User

main

a guest
Mar 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.17 KB | None | 0 0
  1. #include "head.hpp"
  2.  
  3. /*
  4. void add_beg(lista *&beg, lista *&end);
  5. void add_end(lista *&beg, lista *&end);
  6. void add_mid(lista *&beg, lista *&end);
  7. void rem_beg(lista *&beg, lista *&end);
  8. void rem_end(lista *&beg, lista *&end);
  9. bool rem_one(lista *&beg, lista *&end, std::string toremove);
  10. void rem_all(lista *&beg, lista *&end, std::string toremove);
  11. void find(lista *beg, std::string searchkey);
  12. void show(lista *ptr, int direction);
  13. void edit(lista *beg);
  14. void save(lista *ptr, int direction);
  15. */
  16.  
  17. int main() {
  18.     srand(time(NULL));
  19.     lista *beg = nullptr;
  20.     lista *end = nullptr;
  21.  
  22.     while (1) {
  23.         int option = 0;
  24.         std::string toremove = "";
  25.         int direction = 0;
  26.         std::string searchkey = "";
  27.  
  28.         std::cout << "\n\n=======================";
  29.         std::cout << "\nOpcje:";
  30.         std::cout
  31.             << "\n\t   0 exit"
  32.             << "\n\t   1 void add_beg();"
  33.             << "\n\t   2 void add_end();"
  34.             << "\n\t   3 void add_mid();"
  35.             << "\n\t   4 void rem_beg();"
  36.             << "\n\t   5 void rem_end();"
  37.             << "\n\t   6 bool rem_one();"
  38.             << "\n\t   7 void rem_all();"
  39.             << "\n\t   8 void find();"
  40.             << "\n\t   9 void show() (+ 1 beg to end, 2 end to beg);"
  41.             << "\n\t  10 void edit();"
  42.             << "\n\t  11 void save(); (+ 1 beg to end, 2 end to beg)";
  43.         std::cout << "\nProsze wybrac opcje: ";
  44.         std::cin >> option;
  45.         system("cls");
  46.  
  47.         switch (option) {
  48.         case 0:
  49.             //exit
  50.             break;
  51.         case 1:
  52.             add_beg(beg, end);
  53.             break;
  54.         case 2:
  55.             add_end(beg, end);
  56.             break;
  57.         case 3:
  58.             add_mid(beg, end);
  59.             break;
  60.         case 4:
  61.             rem_beg(beg, end);
  62.             break;
  63.         case 5:
  64.             rem_end(beg, end);
  65.             break;
  66.         case 6:
  67.             std::cout << "\nProsze podac nazwisko do usuniecia: ";
  68.             std::cin >> toremove;
  69.             if (rem_one(beg, end, toremove)) {
  70.                 //std::cout << "\nUsunieto element.";
  71.             }
  72.             else {
  73.                 std::cout << "\nBrak elementu do usuniecia.";
  74.             };
  75.             break;
  76.         case 7:
  77.             std::cout << "\nProsze podac nazwisko do usuniecia: ";
  78.             std::cin >> toremove;
  79.             rem_all(beg, end, toremove);
  80.             break;
  81.         case 8:
  82.             std::cout << "\nProsze podac klucz do wyszukiwania: ";
  83.             std::cin >> searchkey;
  84.             std::cout << "\nElementy pasujace do podanego klucza:";
  85.             find(beg, searchkey);
  86.             break;
  87.         case 9:
  88.             //std::cout << "\nProsze podac kierunek wyswietlania listy (1 beg to end, 2 end to beg): ";
  89.             std::cin >> direction;
  90.             if (direction == 1) {
  91.                 std::cout << "\nWyswietlanie listy od poczatku: ";
  92.                 show(beg, direction);
  93.             }
  94.             else {
  95.                 std::cout << "\nWyswietlanie listy od konca: ";
  96.                 show(end, direction);
  97.             };
  98.             break;
  99.         case 10:
  100.             std::cout << "\nProsze podac klucz do wyszukiwania elementow do edycji (najlepiej pesel): ";
  101.             std::cin >> searchkey;
  102.             std::cout << "\nElementy pasujace do podanego klucza:";
  103.             edit(beg, searchkey);
  104.             break;
  105.         case 11:
  106.             //std::cout << "\nProsze podac kierunek zapisywania listy (1 beg to end, 2 end to beg): ";
  107.             std::cin >> direction;
  108.             if (direction == 1) {
  109.                 save(beg, direction);
  110.             }
  111.             else {
  112.                 save(end, direction);
  113.             };
  114.             break;
  115.         case 99:
  116.             for (int i = 0; i < 12; i++) {
  117.                 add_beg(beg, end);
  118.                 add_end(beg, end);
  119.             }
  120.             break;
  121.         default:
  122.             break;
  123.         };
  124.         if (option == 0) { break; };
  125.     };
  126.  
  127.     return 0;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement