Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "head.hpp"
- /*
- void add_beg(lista *&beg, lista *&end);
- void add_end(lista *&beg, lista *&end);
- void add_mid(lista *&beg, lista *&end);
- void rem_beg(lista *&beg, lista *&end);
- void rem_end(lista *&beg, lista *&end);
- bool rem_one(lista *&beg, lista *&end, std::string toremove);
- void rem_all(lista *&beg, lista *&end, std::string toremove);
- void find(lista *beg, std::string searchkey);
- void show(lista *ptr, int direction);
- void edit(lista *beg);
- void save(lista *ptr, int direction);
- */
- int main() {
- srand(time(NULL));
- lista *beg = nullptr;
- lista *end = nullptr;
- while (1) {
- int option = 0;
- std::string toremove = "";
- int direction = 0;
- std::string searchkey = "";
- std::cout << "\n\n=======================";
- std::cout << "\nOpcje:";
- std::cout
- << "\n\t 0 exit"
- << "\n\t 1 void add_beg();"
- << "\n\t 2 void add_end();"
- << "\n\t 3 void add_mid();"
- << "\n\t 4 void rem_beg();"
- << "\n\t 5 void rem_end();"
- << "\n\t 6 bool rem_one();"
- << "\n\t 7 void rem_all();"
- << "\n\t 8 void find();"
- << "\n\t 9 void show() (+ 1 beg to end, 2 end to beg);"
- << "\n\t 10 void edit();"
- << "\n\t 11 void save(); (+ 1 beg to end, 2 end to beg)";
- std::cout << "\nProsze wybrac opcje: ";
- std::cin >> option;
- system("cls");
- switch (option) {
- case 0:
- //exit
- break;
- case 1:
- add_beg(beg, end);
- break;
- case 2:
- add_end(beg, end);
- break;
- case 3:
- add_mid(beg, end);
- break;
- case 4:
- rem_beg(beg, end);
- break;
- case 5:
- rem_end(beg, end);
- break;
- case 6:
- std::cout << "\nProsze podac nazwisko do usuniecia: ";
- std::cin >> toremove;
- if (rem_one(beg, end, toremove)) {
- //std::cout << "\nUsunieto element.";
- }
- else {
- std::cout << "\nBrak elementu do usuniecia.";
- };
- break;
- case 7:
- std::cout << "\nProsze podac nazwisko do usuniecia: ";
- std::cin >> toremove;
- rem_all(beg, end, toremove);
- break;
- case 8:
- std::cout << "\nProsze podac klucz do wyszukiwania: ";
- std::cin >> searchkey;
- std::cout << "\nElementy pasujace do podanego klucza:";
- find(beg, searchkey);
- break;
- case 9:
- //std::cout << "\nProsze podac kierunek wyswietlania listy (1 beg to end, 2 end to beg): ";
- std::cin >> direction;
- if (direction == 1) {
- std::cout << "\nWyswietlanie listy od poczatku: ";
- show(beg, direction);
- }
- else {
- std::cout << "\nWyswietlanie listy od konca: ";
- show(end, direction);
- };
- break;
- case 10:
- std::cout << "\nProsze podac klucz do wyszukiwania elementow do edycji (najlepiej pesel): ";
- std::cin >> searchkey;
- std::cout << "\nElementy pasujace do podanego klucza:";
- edit(beg, searchkey);
- break;
- case 11:
- //std::cout << "\nProsze podac kierunek zapisywania listy (1 beg to end, 2 end to beg): ";
- std::cin >> direction;
- if (direction == 1) {
- save(beg, direction);
- }
- else {
- save(end, direction);
- };
- break;
- case 99:
- for (int i = 0; i < 12; i++) {
- add_beg(beg, end);
- add_end(beg, end);
- }
- break;
- default:
- break;
- };
- if (option == 0) { break; };
- };
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement