Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 21.05 KB | None | 0 0
  1. ///Includes...
  2.  
  3. ///==========================================================================================================
  4.  
  5. #include <iostream> /// pentru cin si cout si namespace ul std
  6. #include <algorithm> /// pentru functia sort
  7. #include <stdio.h> /// pentru printf sau pentru system
  8. #include <stdlib.h> /// pentru system in concordanta cu stdio
  9. #include <cstring> ///pentru strlen, strcmp etc.
  10. #include <vector> ///pentru vectori
  11. #include <complex> ///pentru stringstream convert (C++0x)
  12. #include <typeinfo> /// pentru convert
  13. #include <windows.h>
  14.  
  15. ///==========================================================================================================
  16.  
  17. ///Namespace uri
  18.  
  19. using std::cin;  ///for cin
  20. using std::cout;  ///for cout
  21. using std::vector; ///for vector
  22. using std::string;  ///for string
  23. using std::endl;  ///for endline
  24. using std::istream; ///for istream
  25. using std::ostream; ///for ostream
  26.  
  27. ///the namespace verify class defines
  28.  
  29. #define load_false static const bool val = false;\
  30. public:\
  31.     static const bool get()\
  32.     {return val;}
  33. #define load_true static const bool val = true;\
  34. public:\
  35.     static const bool get()\
  36.     {return val;}
  37.  
  38. namespace verify ///I can use only one from all 5 classes (2 / 10) thanks to verify::class_name
  39. {
  40.     template<typename T>
  41.     class is_int{load_false};
  42.  
  43.     template<>
  44.     class is_int<int>{load_true};
  45.  
  46.     template<typename T>
  47.     class is_float{load_false};
  48.  
  49.     template<>
  50.     class is_float<float>{load_true};
  51.  
  52.     template<typename T>
  53.     class is_unsigned_t{load_false};
  54.  
  55.     template<>
  56.     class is_unsigned_t<unsigned>{load_true};
  57.  
  58.     template<typename T>
  59.     class is_string{load_false};
  60.  
  61.     template<>
  62.     class is_string<string>{load_true};
  63.  
  64.     template<typename T>
  65.     class is_char{load_false};
  66.  
  67.     template<>
  68.     class is_char<char>{load_true};
  69. };
  70.  
  71. using namespace verify;
  72.  
  73. #define forp(i, n) for(int i=0; i<n; i++)
  74. #define _X dwSize.X
  75. #define _Y dwSize.Y
  76. #define GCSBI GetConsoleScreenBufferInfo
  77. #define FCOC  FillConsoleOutputCharacter
  78. #define FCOA  FillConsoleOutputAttribute
  79. #define SCCP  SetConsoleCursorPosition
  80. #define GSH_S_O_H   GetStdHandle (STD_OUTPUT_HANDLE)
  81.  
  82.  
  83.  
  84. void enter()
  85. {
  86.     printf("Te rog sa apesi enter sau sa astepti 30 de secunde \n");
  87.     system("timeout 30 > null");
  88. }
  89.  
  90. void clearscreen()
  91. {
  92.     DWORD n;
  93.     COORD coord = {0};
  94.     CONSOLE_SCREEN_BUFFER_INFO csbi;
  95.     GCSBI(GSH_S_O_H, &csbi );
  96.     FCOC (GSH_S_O_H, TEXT ( ' ' ), csbi._X * csbi._Y, coord, &n );
  97.     GCSBI(GSH_S_O_H, &csbi );
  98.     FCOA (GSH_S_O_H, csbi.wAttributes, csbi._X * csbi._Y, coord, &n );
  99.     SCCP (GSH_S_O_H, coord );
  100. }
  101.  
  102.  
  103. ///for unsigned
  104. string split (string& s, string which)
  105. {
  106.     size_t pos_start = 0, pos_end, len = which.length();
  107.     string token, combine;
  108.     while ((pos_end = s.find (which, pos_start)) != string::npos)
  109.     {
  110.         token = s.substr (pos_start, pos_end - pos_start);
  111.         pos_start = pos_end + len;
  112.         combine += token;
  113.     }
  114.  
  115.     combine += s.substr(pos_start);
  116.     s = combine;
  117.     return combine;
  118. }
  119.  
  120. bool isNumber(const char* s, char compl1 ='-')
  121. {
  122.     /// Verificare sir de caractere daca formeaza un numar
  123.     int len = strlen(s);
  124.     forp(i, len)
  125.     if (s[i] < '0' || s[i] > '9')
  126.     {
  127.         ///Cazul pt negativ
  128.         if(compl1 == '-')
  129.         {
  130.             if(!(s[i]=='-' && (s[i+1] >= '0' && s[i+1] <= '9')))
  131.                 return false;
  132.         }
  133.         else
  134.             return false;
  135.     }
  136.  
  137.     return true;
  138.     /// ...
  139. }
  140.  
  141. void nicely_intro()
  142. {
  143.     cout<<"User@>";
  144. }
  145.  
  146. void error(int e)
  147. {
  148.     switch(e)
  149.     {
  150.     case 1:
  151.         printf("Error 001: You inserted a string in a number variable!");
  152.         break;
  153.  
  154.     case 2:
  155.         printf("Error 002: You inserted a negative number!");
  156.         break;
  157.  
  158.     case 3:
  159.         printf("Error 003: You want to compare something NULL");
  160.         break;
  161.  
  162.     case 4:
  163.         printf("Error 004: You inserted a bad number");
  164.         break;
  165.  
  166.     default:
  167.         break;
  168.     }
  169.     exit(e);
  170. }
  171.  
  172.  
  173. void warning(int e)
  174. {
  175.     switch(e)
  176.     {
  177.     case 1:
  178.         printf("Warning 001: You introduced a string type, it will be converted to 0. Bypass!\n");
  179.         break;
  180.  
  181.     case 2:
  182.         printf("Warning 002: You inserted a negative number, it will be converted to positive number!\n");
  183.         printf("e.g -3 => 3\n");
  184.         break;
  185.  
  186.     case 3:
  187.         printf("Warning 003: You inserted a bad number!\n");
  188.         break;
  189.  
  190.     default:
  191.         break;
  192.     }
  193. }
  194.  
  195.  
  196. template <typename T>
  197. T getline_type(istream &in)
  198. {
  199.     string read;
  200.     in>>read;
  201.     T temp;
  202.     if (is_int<T>::get() || is_unsigned_t<T>::get() || is_float<T>::get())
  203.         if(!isNumber(read.c_str(), '-'))
  204.             warning(1);
  205.     if(is_unsigned_t<T>::get())
  206.     {
  207.         char minus_unsigned = read[0];
  208.         if (minus_unsigned == '-')
  209.         {
  210.             warning(2);
  211.             string unsigned_convert = split(read, "-");
  212.             std::stringstream convert(unsigned_convert);
  213.             convert >> temp;
  214.         }
  215.         else
  216.         {
  217.             std::stringstream convert(read);
  218.             convert >> temp;
  219.         }
  220.         return temp;
  221.     }
  222.  
  223.     std::stringstream convert(read);
  224.     convert >> temp;
  225.     return temp;
  226. }
  227.  
  228. ///=============================================================================================================
  229.  
  230. ///Classess
  231.  
  232. ///1) Class nod
  233.  
  234. ///==========================================================================================================
  235.  
  236. template <class T>
  237. class Nod
  238. {
  239.  
  240. protected:
  241.     T info;
  242.     Nod<T>* next;
  243.  
  244. public:
  245.     Nod<T>()
  246.     {
  247.         next = NULL;
  248.     }
  249.     Nod<T>(T temp)
  250.     {
  251.         info = temp;
  252.         next = NULL;
  253.     }
  254.     void setter(T temp)
  255.     {
  256.         info = temp;
  257.     }
  258.     void setnext(Nod<T> *setnext)
  259.     {
  260.         next = setnext;
  261.     }
  262.     Nod<T>* getnext()
  263.     {
  264.         return next;
  265.     }
  266.     T getdata()
  267.     {
  268.         return info;
  269.     }
  270.     template <class U>
  271.     friend istream& operator>>(istream& in, Nod<U>* nod);
  272.     template <class U>
  273.     friend ostream& operator<<(ostream& out, Nod<U>* nod);
  274. };
  275.  
  276. template <class T>
  277. istream& operator>>(istream& in, Nod<T>* nod)
  278. {
  279.     T info;
  280.     info = getline_type<T>(cin);
  281.     nod->info = info;
  282.     return in;
  283. }
  284.  
  285. template <class T>
  286. ostream& operator<<(ostream& out, Nod<T>* nod)
  287. {
  288.     T info;
  289.     info = nod->info;
  290.     nod->next = nod;
  291.     out<<info;
  292.     return out;
  293. }
  294.  
  295. ///==========================================================================================================
  296.  
  297. ///2) Class Nod_dublu
  298.  
  299. ///==========================================================================================================
  300.  
  301. template <class T>
  302. class Nod_dublu: public Nod<T>
  303. {
  304. protected:
  305.     Nod<T> *ante;  ///nodul anterior
  306.  
  307. public: ///mostenirea
  308.     Nod_dublu<T>():Nod<T>(), ante() { }
  309.     Nod_dublu<T>(T init):Nod<T>(init), ante() { }
  310.     ~Nod_dublu<T>()
  311.     {
  312.         delete ante;
  313.     }
  314.     Nod_dublu<T>* convert(Nod<T>* temp)
  315.     {
  316.         Nod_dublu<T>* temp_dublu = new Nod_dublu();
  317.         temp_dublu->setante();
  318.         temp_dublu->setter(temp->getdata());
  319.         temp_dublu->setnext(temp->getnext());
  320.         return temp_dublu;
  321.     }
  322.     Nod<T>* getante()
  323.     {
  324.         return ante;
  325.     }
  326.     void setante(Nod<T>* temp = NULL)
  327.     {
  328.         ante = temp;
  329.     }
  330.     Nod<T>* convert_front(Nod_dublu<T>* temp)
  331.     {
  332.         Nod<T>* gamma = new Nod<T>(temp->getdata());
  333.         T i;
  334.         try
  335.         {
  336.             if(temp == NULL)
  337.             {
  338.                 i = temp->getdata();
  339.                 throw i;
  340.             }
  341.             else
  342.             {
  343.                 gamma->setnext(temp->getnext());
  344.             }
  345.         }
  346.         catch(T i)
  347.         {
  348.             error(3);
  349.         }
  350.         return gamma;
  351.     }
  352.  
  353.     Nod_dublu<T>* convert_back(Nod<T>* temp)
  354.     {
  355.         T i;
  356.         try
  357.         {
  358.             if(temp == NULL)
  359.             {
  360.                 i = temp->getdata();
  361.                 throw i;
  362.             }
  363.             else
  364.             {
  365.                 this->setter(temp->getdata());
  366.                 this->setnext(temp->getnext());
  367.                 this->setante(NULL);
  368.             }
  369.         }
  370.         catch(T i)
  371.         {
  372.             error(3);
  373.         }
  374.         return this;
  375.     }
  376.  
  377.     template <class U>
  378.     Nod_dublu<U>* operator=(Nod_dublu<U>* temp)
  379.     {
  380.         if(temp->ante == NULL)
  381.             this->ante = NULL;
  382.         if(temp->next == NULL)
  383.         {
  384.             this->ante = temp->ante;
  385.             this->next = NULL;
  386.             this->info = temp->info;
  387.         }
  388.         else
  389.         {
  390.             if(this->ante == NULL && this->info == NULL)
  391.             {
  392.                 perror(ERROR_ACCESS_DENIED);
  393.             }
  394.             else
  395.             {
  396.                 this->ante = temp->ante;
  397.                 this->info = temp->info;
  398.                 this->next = temp->next;
  399.                 return this;
  400.             }
  401.         }
  402.     }
  403.  
  404.     template <class U>
  405.     friend istream& operator>>(istream& in, Nod_dublu<U>* nod);
  406.     template <class U>
  407.     friend ostream& operator<<(ostream& out, Nod_dublu<U>* nod);
  408. };
  409.  
  410.  
  411. template <class T>
  412. istream& operator>>(istream& in, Nod_dublu<T>* nod)
  413. {
  414.     T info;
  415.     info = getline_type<T>(cin);
  416.     nod->info = info;
  417.     return in;
  418. }
  419.  
  420. template <class T>
  421. ostream& operator<<(ostream& out, Nod_dublu<T>* nod)
  422. {
  423.     out<<nod->info;
  424.     return out;
  425. }
  426.  
  427. ///==========================================================================================================
  428.  
  429.  
  430. ///3) class LDI
  431. template <class T>
  432. class LDI
  433. {
  434.     Nod_dublu<T>** elemente;
  435.     int elem;
  436.     int i; ///evidence for push_back and push_front
  437. public:
  438.     LDI<T>(int cate_elemente = 0)
  439.     {
  440.         elem = cate_elemente;
  441.         i = 0;
  442.         elemente = new Nod_dublu<T>*[cate_elemente];
  443.     }
  444.     ~LDI<T>()
  445.     {
  446.  
  447.     }
  448.     void reset_space(int cate_elemente)
  449.     {
  450.         elemente = new Nod_dublu<T>*[cate_elemente];
  451.         elem = cate_elemente;
  452.         i = 0;
  453.     }
  454.     int space()
  455.     {
  456.         return this->elem;
  457.     }
  458.     Nod_dublu<T>** elemente_return()
  459.     {
  460.         return elemente;
  461.     }
  462.     void push_front(Nod_dublu<T>* head); ///push;
  463.     void push_back(Nod_dublu<T>* back);
  464.     void sort_LDI();
  465.     virtual void citire(istream& in, Nod_dublu<T>* inserter);
  466.     template <class U>
  467.     friend istream& operator>>(istream& in, LDI<U>& ldi);
  468.     template <class U>
  469.     friend ostream& operator<<(ostream& out, LDI<U>& ldi);
  470.     template <class U>
  471.     LDI<U> operator=(LDI<U> ldi)
  472.     {
  473.         this->elem = ldi.elem;
  474.         this->elemente = new Nod_dublu<U>*[ldi.elem];
  475.         for(int i=0; i<elem; i++)
  476.             this->elemente[i] = ldi.elemente[i];
  477.         return *this;
  478.     }
  479.     int size()
  480.     {
  481.         int i=0;
  482.         while(elemente[i]!=NULL)
  483.             i++;
  484.         return i;
  485.     }
  486. };
  487.  
  488.  
  489. template <class T>
  490. void LDI<T>::citire(istream &in, Nod_dublu<T>* inserter)
  491. {
  492.  
  493.     cout<<"Doriti sa bagati numarul in fata sau in spate?"<<endl;
  494.     cout<<"1 - fata, 2 - spate"<<endl;
  495.     int type_read;
  496.     type_read = getline_type<int>(cin);
  497.     if(type_read == 1)
  498.         push_front(inserter);
  499.     else if(type_read == 2)
  500.         push_back(inserter);
  501.     else
  502.         error(2);
  503. }
  504.  
  505. template <class T>
  506. istream& operator>>(istream& in, LDI<T>& ldi)
  507. {
  508.     ldi.reset_space(ldi.elem);
  509.     for(int i=0; i<ldi.elem; i++)
  510.     {
  511.         cout<<"Nodul "<<i<<" :"<<endl;
  512.         Nod_dublu<T>* temp = new Nod_dublu<T>();
  513.         cin>>temp;
  514.         ldi.citire(cin, temp);
  515.     }
  516.     return in;
  517. }
  518.  
  519.  
  520. template <class T>
  521. void LDI<T>::sort_LDI()
  522. {
  523.     LDI<T> sort_t(elem);
  524.     for(int i=0; i<elem; i++)
  525.     {
  526.         T key;
  527.         int j;
  528.         key = elemente[i]->getdata();
  529.         j = i - 1;
  530.         while(j>=0 && (elemente[j])->getdata() > key)
  531.         {
  532.             elemente[j+1]=elemente[j];
  533.             j--;
  534.         }
  535.         elemente[j + 1] = new Nod_dublu<T>(key);
  536.     }
  537. }
  538.  
  539. template <class T>
  540. void LDI<T>::push_back(Nod_dublu<T>* back)
  541. {
  542.     if(back == NULL)
  543.         error(3);
  544.     Nod_dublu<T>* before = new Nod_dublu<T>();
  545.     before->setter(back->getdata());
  546.     before->setnext(back->getnext());
  547.     if (before->getnext() != NULL)
  548.         before->getante()->setnext(before);
  549.     else
  550.         elemente[i++] = before;
  551. }
  552.  
  553. template <class T>
  554. void LDI<T>::push_front(Nod_dublu<T>* head)
  555. {
  556.     LDI<T> temp(elem);
  557.     temp.push_back(head);
  558.     for(int j=0; j<i; j++)
  559.         temp.push_back(elemente[j]);
  560.     i++;
  561.     elemente = temp.elemente;
  562. }
  563.  
  564. template <class T>
  565. ostream& operator<<(ostream& out, LDI<T>& ldi)
  566. {
  567.     int e = ldi.elem;
  568.     for(int i=0; i<e; i++)
  569.         cout<<(ldi.elemente[i])<<" ";
  570.  
  571.     cout<<endl;
  572.     return out;
  573. }
  574.  
  575. template <class T>
  576. class LSI:public LDI<T>
  577. {
  578.     static int all;
  579. public:
  580.     LSI<T>(int cate_elemente = 0):LDI<T>(cate_elemente) {};
  581.     void citire(istream& in, Nod_dublu<T>* temp)
  582.     {
  583.         this->push_back(temp);
  584.     }
  585.     template <class U>
  586.     friend istream& operator>>(istream& in, LSI<U>& lsi);
  587. };
  588.  
  589. template <class T>
  590. istream& operator>>(istream& in, LSI<T>& lsi)
  591. {
  592.     for(int i=0; i<lsi.space(); i++)
  593.     {
  594.         cout<<"Nodul "<<i<<": "<<endl;
  595.         Nod_dublu<T>* temp = new Nod_dublu<T>();
  596.         cin>>temp;
  597.         lsi.citire(cin, temp);
  598.     }
  599.     return in;
  600. }
  601.  
  602.  
  603. template <class T>
  604. void sort_list(LDI<T>& lista)
  605. {
  606.     lista.sort_LDI();
  607.     cout<<"Sortat cu succes"<<endl;
  608.     cout<<"Am terminat"<<endl;
  609. }
  610.  
  611.  
  612.  
  613. class count_list
  614. {
  615.     static int list_linked; ///to count the linked list
  616.     static int list_double; /// to count the double linked list
  617.     static int list_simple; ///to count the simple linked list
  618. public:
  619.     static void set_evidence(int e, string h)
  620.     {
  621.         if(h == "d")
  622.             list_double = e;
  623.         if(h == "s")
  624.             list_simple = e;
  625.         list_linked = (list_simple + list_double);
  626.     }
  627.     static vector<int> get()
  628.     {
  629.         vector<int> get_ve;
  630.         get_ve.push_back(list_double);
  631.         get_ve.push_back(list_simple);
  632.         get_ve.push_back(list_linked);
  633.         return get_ve;
  634.     }
  635. };
  636.  
  637. int count_list::list_linked = 0; ///to count the linked list
  638. int count_list::list_double = 0; /// to count the double linked list
  639. int count_list::list_simple = 0; ///to count the simple linked lis
  640.  
  641. template <class T>
  642. class count_vector
  643. {
  644.     static vector < LDI<T> > double_list;
  645.     static int counter;
  646.     static vector < LDI<T> > single_list;
  647.     static int counter1;
  648.  
  649. public:
  650.     static void setter(LDI<T> temp, int ok = 1)
  651.     {
  652.         if(ok == 1)
  653.         {
  654.             double_list.push_back(temp);
  655.             counter++;
  656.         }
  657.         if(ok == 2)
  658.         {
  659.             single_list.push_back(temp);
  660.             counter1++;
  661.         }
  662.     }
  663.     static void double_list_print()
  664.     {
  665.         cout<<"Size: "<<counter;
  666.         printf("\n");
  667.         cout<<"Listele citite sunt: "<<endl;
  668.         for(int i = 0; i<counter; i++)
  669.         {
  670.             cout<<"Lista "<<i<<":\n";
  671.             cout<<double_list[i];
  672.         }
  673.     }
  674.     static void single_list_print()
  675.     {
  676.         cout<<"Size: "<<counter1;
  677.         printf("\n");
  678.         cout<<"Listele citite sunt: "<<endl;
  679.         for(int i = 0; i<counter1; i++)
  680.         {
  681.             cout<<"Lista "<<i<<":\n";
  682.             cout<<single_list[i];
  683.         }
  684.     }
  685.     static int counter_1()
  686.     {
  687.         return counter1;
  688.     }
  689.     static int counter_0()
  690.     {
  691.         return counter;
  692.     }
  693. };
  694.  
  695. template<typename T>
  696. vector < LDI<T> > count_vector<T>::double_list; // only change here
  697. template<typename T>
  698. vector < LDI<T> > count_vector<T>::single_list; // only change here
  699. template <typename T>
  700. int  count_vector<T>::counter1 = 0;
  701. template <typename T>
  702. int  count_vector<T>::counter = 0;
  703.  
  704. /// in c++11
  705.  
  706.  
  707. template <class T>
  708. void LI_meniu(int x)
  709. {
  710.     int n;
  711.     cout<<"Cate liste vrei sa citesti?"<<endl;
  712.     n = getline_type<unsigned>(cin);
  713.     if(n == 0)
  714.         error(1);
  715.     cout<<"Vei citi urmatoarele "<<n<<" liste"<<endl;
  716.     int d = 0; ///for double
  717.     int s = 0; ///for simple
  718.     forp(i, n)
  719.     {
  720.         cout<<"Lista "<<i<<":"<<endl;
  721.         int k;
  722.         cout<<"Introduceti spatiul pentru lista "<<endl;
  723.         k = getline_type<unsigned>(cin);
  724.         if (k == 0)
  725.             error(1);
  726.         LDI<T>* lista_i;
  727.         if (x == 2)
  728.         {
  729.             lista_i = new LSI<T>(k);
  730.             s++;
  731.             count_list::set_evidence(s, "s");
  732.         }
  733.         if (x == 1)
  734.         {
  735.             lista_i = new LDI<T>(k); ///Cast
  736.             d++;
  737.             count_list::set_evidence(d, "d");
  738.         }
  739.         cin>>*lista_i;
  740.         string s;
  741.         cout<<"Doriti sa le sortati? (Yes / No)"<<endl;
  742.         cin>>s;
  743.         if(s == "No") cout<<"Am terminat"<<endl;
  744.         if(s == "Yes") sort_list<T>(*lista_i);
  745.         count_vector<T>::setter(*lista_i, x);
  746.     }
  747.     enter();
  748. }
  749.  
  750.  
  751. void menu_database(int n)
  752. {
  753.     clearscreen();
  754.     if(n == 3)
  755.         cout<<"Ai selectat lista dubla sau simpla"<<endl;
  756.     if(n == 1)
  757.         cout<<"Ai selectat lista dubla inlantuita"<<endl;
  758.     if(n == 2)
  759.         cout<<"Ai selectat lista simpla inlantuita"<<endl;
  760.     printf("1) Int\n");
  761.     printf("2) Unsigned\n");
  762.     printf("3) Char\n");
  763.     printf("4) String\n");
  764.     printf("5) Float\n");
  765.     printf("7) Back\n");
  766. }
  767.  
  768. template <class T>
  769. void database_type()
  770. {
  771.     if(is_int<T>::get())
  772.     {
  773.         printf("=====================================================");
  774.         printf("\nInt\n");
  775.     }
  776.     else if(is_float<T>::get())
  777.     {
  778.         printf("=====================================================");
  779.         printf("\nFloat\n");
  780.  
  781.     }
  782.     else if(is_unsigned_t<T>::get())
  783.     {
  784.         printf("=====================================================");
  785.         printf("\nUnsigned\n");
  786.  
  787.     }
  788.     else if(is_string<T>::get())
  789.     {
  790.         printf("=====================================================");
  791.         printf("\nString\n");
  792.  
  793.     }
  794.     else if(is_char<T>::get())
  795.     {
  796.         printf("=====================================================");
  797.         printf("\nChar\n");
  798.  
  799.     }
  800. }
  801.  
  802. template <class T>
  803. void afisare(int n)
  804. {
  805.     if(n == 0)
  806.         if(count_vector<T>::counter_0() != 0)
  807.         {
  808.             database_type<T>();
  809.             count_vector<T>::double_list_print();
  810.         }
  811.  
  812.     if(n == 1)
  813.     {
  814.         if(count_vector<T>::counter_1() != 0)
  815.         {
  816.             database_type<T>();
  817.             count_vector<T>::single_list_print();
  818.         }
  819.     }
  820.  
  821. }
  822.  
  823.  
  824. int main()
  825. {
  826.     int n;
  827.     while(true)
  828.     {
  829.         clearscreen();
  830.         printf("Test mode on\nStatus: Complexity = O(n^2), Time of debugging and programming = 24 hours, Headers = 0, Lines = 900");
  831.         printf("\nNumber of Classes: 16, Functions: 54, Templates: 60, Structures: 0");
  832.         printf("\nRealizat de Mihalea Andreas, tema 1!\nSelectati:\n1) Liste dublu inlantuite \n2) Liste simplu inlantuite \n3) Cate liste dublu / simple inlantuite au fost citite!\n4) Exit\n"); ///To optimise the code
  833.         nicely_intro();
  834.         n = getline_type<int>(cin);
  835.         if(n == 1 || n == 2)
  836.         {
  837.             menu_database(n);
  838.             int k;
  839.             nicely_intro();
  840.             k = getline_type<int>(cin);
  841.             switch(k)
  842.             {
  843.             case 1:
  844.                 LI_meniu<int>(n);
  845.                 break;
  846.             case 2:
  847.                 LI_meniu<unsigned>(n);
  848.                 break;
  849.             case 3:
  850.                 LI_meniu<char>(n);
  851.                 break;
  852.             case 4:
  853.                 LI_meniu<string>(n);
  854.                 break;
  855.             case 5:
  856.                 LI_meniu<float>(n);
  857.                 break;
  858.             default:
  859.                 break;
  860.             }
  861.         }
  862.         if(n == 3)
  863.         {
  864.             clearscreen();
  865.             printf("Numarul listelor citite:\n");
  866.             vector<int> ep = count_list::get();
  867.             int ld = ep[0], ls = ep[1];
  868.             printf("Liste inlantuite duble: %d\nListe inlantuite simple: %d\nIn total: %d\n", ls, ld, ls+ld);
  869.             if(ld!=0)
  870.             {
  871.                 printf("Listele duble inlantuite citite sunt:\n");
  872.                 afisare<int>(0);
  873.                 afisare<float>(0);
  874.                 afisare<unsigned>(0);
  875.                 afisare<char>(0);
  876.                 afisare<string>(0);
  877.                 printf("=====================================================\n");
  878.             }
  879.             if(ls!=0)
  880.             {
  881.                 printf("Listele simpla inlantuite citite sunt:\n");
  882.                 afisare<int>(1);
  883.                 afisare<float>(1);
  884.                 afisare<unsigned>(1);
  885.                 afisare<char>(1);
  886.                 afisare<string>(1);
  887.                 printf("=====================================================\n");
  888.             }
  889.             enter();
  890.         }
  891.         if(n == 4)
  892.         {
  893.             clearscreen();
  894.             printf("Ai iesit din program\n");
  895.             exit(0);
  896.         }
  897.  
  898.     }
  899. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement