Advertisement
TShiva

L2.Main

Oct 12th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.36 KB | None | 0 0
  1. #include"L2.h"
  2. #include"MasOfL2.h"
  3. #include<iostream>  
  4. #include<conio.h>
  5.  
  6. using namespace std;
  7.  
  8. void main()
  9. {
  10.    
  11.  
  12.     cout << "Use of class L2:" << endl;
  13.  
  14.     cout << "1 - вставка элемента на место i" << endl;
  15.     cout << "2 - вывести список" << endl;
  16.     cout << "3 - поиск элемента" << endl;
  17.     cout << "4 - переход к списку i" << endl;
  18.     cout << "3 - выбор списка для работы" << endl;
  19.     cout << "0 - создание списка" << endl;
  20.  
  21.  
  22.  
  23.         //Двунаправленный список.
  24.         cout << "Use of class L2:" << endl;
  25.         L2 A;
  26.         MasOfL2 Mas(4);
  27.         int CurOfMas = 0;
  28.         int n = -1;
  29.         while(n!=10){
  30.             cin >> n;
  31.             switch (n) {
  32.  
  33.             case 0: {
  34.                 int i;
  35.                 cout << "выберите место для списка в массиве списков 0 - 3" << endl;
  36.                 cin >> i;
  37.                 if ((i < 0) && (i >= 4)) break;
  38.                 else
  39.                     Mas.PutN(A, i);
  40.                 CurOfMas = i;
  41.                 break;
  42.             }
  43.             case 1: {
  44.  
  45.                 int i = 1;
  46.                 char j = 'q';
  47.  
  48.                 Mas.GetN(CurOfMas).Insert(i, j);
  49.                 break;
  50.             }
  51.  
  52.             case 2: {
  53.                 A.Print();
  54.                 break;
  55.             }
  56.  
  57.             case 3: {
  58.                 int i = 0;
  59.                 cout << "Выберите список для работы " << endl;
  60.                 cin >> i;
  61.                 if ((i < 0) && (i >= 4)) break;
  62.                 CurOfMas = i;
  63.                 break;
  64.             }
  65.             }
  66.  
  67. /*
  68.                 cout << "L2 A" << endl;
  69.                 A.Print();
  70.                 //1.Insert
  71.                 A.Insert(0, 'q');
  72.                 A.Insert(1, 'w');
  73.                 A.Insert(2, 'e');
  74.                 A.Insert(2, 'e');
  75.                 A.Print();
  76.                 A.ExtractCh('q');
  77.                 cout << endl << A.Search('q');
  78.                 cout << endl;
  79.                 L2 B;
  80.                 B = A;
  81.                 */
  82.  
  83.        
  84.             //MasOfL2 a(10);
  85.             //a.PutN(A, 1);
  86.             //a.GetN(1).Print();
  87.             /*
  88.  
  89.  
  90.  
  91.             //2.Print
  92.             cout<<"A.Print(): ";
  93.             A.Print();//q w e
  94.             cout<<endl;
  95.  
  96.             //3.Search
  97.             cout<<"A.Search('q') returned "<<A.Search('q')<<endl;
  98.             cout<<"A.Search('s') returned "<<A.Search('s')<<endl;
  99.             cout<<endl;
  100.  
  101.             //4.Constructor Copy
  102.             L2 B(A);
  103.             cout<<"***L2 B(A)"<<endl<<"B.Print(): ";
  104.             B.Print();//q w e
  105.             cout<<endl<<"***B.Insert(1,'r')"<<endl;
  106.             B.Insert(1,'r');
  107.             cout<<"B.Print(): ";
  108.             B.Print();//q r w e
  109.             cout<<endl;
  110.  
  111.             //5.ExtractCh
  112.             cout<<"***A.ExtractCh('w')"<<endl;
  113.             A.ExtractCh('w');
  114.             cout<<"A.Print(): ";
  115.             A.Print();//q e
  116.             cout<<endl;
  117.  
  118.             //6.operator =
  119.             cout<<"***A=B"<<endl;
  120.             A=B;
  121.             cout<<"A.Print: ";
  122.             A.Print();//q r w e
  123.             cout<<endl;
  124.  
  125.             //7.ExtractI
  126.             cout<<"***A.ExtractI(2)***A.Insert(3,'r')"<<endl;
  127.             A.ExtractI(2);
  128.             A.Insert(3,'r');
  129.             cout<<"A.Print: ";
  130.             A.Print();//q w e r
  131.             cout<<endl;
  132.  
  133.             //8.Len
  134.             cout<<"A.Len="<<A.Len()<<endl;
  135.             getch();
  136.             cout<<endl;
  137.            
  138.  
  139.  
  140.  
  141.             //Массив двунаправленных списков.
  142.             cout<<"Use of class MasOfL2:"<<endl;
  143.             MasOfL2 Mas1(3);
  144.             cout<<"Massive Mas1 was created.Its length equals 3"<<endl;
  145.  
  146.             //Len
  147.             cout<<"Mas1.Len() returned "<<Mas1.Len()<<endl;
  148.  
  149.             //PutN
  150.             cout<<"***Mas1.PutN('q w e r',1)"<<endl;
  151.             Mas1.PutN(A,1);//Mas1[1]=q w e r
  152.  
  153.             //GetN
  154.             cout<<"***Mas1[1]=";
  155.             Mas1.GetN(1).Print();//q w e r
  156.  
  157.             //operator=
  158.             MasOfL2 Mas2(3);
  159.             Mas2=Mas1;
  160.             cout<<"***Mas2=Mas1"<<endl<<endl<<"***Mas2[1]=";
  161.             Mas2.GetN(1).Print();//q w e r
  162.             cout<<"It's length equals "<<Mas1.GetN(1).Len()<<endl;
  163.             cout<<"***Mas2[2]=";
  164.             Mas2.GetN(2).Print();//empty
  165.             cout<<"It's length equals "<<Mas2.GetN(2).Len()<<endl;
  166.             cout<<"***Mas2[3]=";
  167.             Mas2.GetN(3).Print();//empty
  168.             cout<<"It's length equals "<<Mas2.GetN(3).Len()<<endl;
  169.  
  170.  
  171.  
  172.             //Constructor Copy
  173.             cout<<endl<<endl<<endl;
  174.             Mas2.PutN(B,2);//Mas2[2]=q r w e
  175.             Mas2.PutN(B,3);//Mas2[3]=q r w e
  176.             Mas2.GetN(3).ExtractI(1);//Mas2[3]=r w e
  177.             cout<<"It must be   q r w e: ";
  178.             B.Print();//q r w e
  179.             cout<<"it must be  r w e: ";
  180.             Mas2.GetN(3).Print();//r w e
  181.             cout<<endl<<endl<<endl;
  182.             //  cout<<Mas2.Len()<<endl<<Mas2.GetN(3).Len()<<endl;
  183.  
  184.             //  MasOfL2 Mas3(Mas2);
  185.  
  186.  
  187.  
  188.  
  189.             //  A.Print();//q w e r
  190.             //  B.Print();//q r w e
  191.  
  192.  
  193.  
  194.  
  195.  
  196.             cout<<"All functions are tested. Demonstration is finished."<<endl;
  197.             cout<<"From all of us in Aerosmith to all of you: Remember, "<<endl<<"the light in the end of the tunnel may be you."<<endl<<"  GOOD BYE"<<endl<<endl;
  198.             getch();
  199.             for(int i=0; i<12; i++)
  200.             {
  201.             for(int j=0; j<i; j++)cout<<" ";
  202.             cout<<"Press any key "<<endl;
  203.             }
  204.             cout<<"            ";
  205.  
  206.            
  207.             */
  208.         }
  209.    
  210.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement