Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"L2.h"
- #include"MasOfL2.h"
- #include<iostream>
- #include<conio.h>
- using namespace std;
- void main()
- {
- cout << "Use of class L2:" << endl;
- cout << "1 - вставка элемента на место i" << endl;
- cout << "2 - вывести список" << endl;
- cout << "3 - поиск элемента" << endl;
- cout << "4 - переход к списку i" << endl;
- cout << "3 - выбор списка для работы" << endl;
- cout << "0 - создание списка" << endl;
- //Двунаправленный список.
- cout << "Use of class L2:" << endl;
- L2 A;
- MasOfL2 Mas(4);
- int CurOfMas = 0;
- int n = -1;
- while(n!=10){
- cin >> n;
- switch (n) {
- case 0: {
- int i;
- cout << "выберите место для списка в массиве списков 0 - 3" << endl;
- cin >> i;
- if ((i < 0) && (i >= 4)) break;
- else
- Mas.PutN(A, i);
- CurOfMas = i;
- break;
- }
- case 1: {
- int i = 1;
- char j = 'q';
- Mas.GetN(CurOfMas).Insert(i, j);
- break;
- }
- case 2: {
- A.Print();
- break;
- }
- case 3: {
- int i = 0;
- cout << "Выберите список для работы " << endl;
- cin >> i;
- if ((i < 0) && (i >= 4)) break;
- CurOfMas = i;
- break;
- }
- }
- /*
- cout << "L2 A" << endl;
- A.Print();
- //1.Insert
- A.Insert(0, 'q');
- A.Insert(1, 'w');
- A.Insert(2, 'e');
- A.Insert(2, 'e');
- A.Print();
- A.ExtractCh('q');
- cout << endl << A.Search('q');
- cout << endl;
- L2 B;
- B = A;
- */
- //MasOfL2 a(10);
- //a.PutN(A, 1);
- //a.GetN(1).Print();
- /*
- //2.Print
- cout<<"A.Print(): ";
- A.Print();//q w e
- cout<<endl;
- //3.Search
- cout<<"A.Search('q') returned "<<A.Search('q')<<endl;
- cout<<"A.Search('s') returned "<<A.Search('s')<<endl;
- cout<<endl;
- //4.Constructor Copy
- L2 B(A);
- cout<<"***L2 B(A)"<<endl<<"B.Print(): ";
- B.Print();//q w e
- cout<<endl<<"***B.Insert(1,'r')"<<endl;
- B.Insert(1,'r');
- cout<<"B.Print(): ";
- B.Print();//q r w e
- cout<<endl;
- //5.ExtractCh
- cout<<"***A.ExtractCh('w')"<<endl;
- A.ExtractCh('w');
- cout<<"A.Print(): ";
- A.Print();//q e
- cout<<endl;
- //6.operator =
- cout<<"***A=B"<<endl;
- A=B;
- cout<<"A.Print: ";
- A.Print();//q r w e
- cout<<endl;
- //7.ExtractI
- cout<<"***A.ExtractI(2)***A.Insert(3,'r')"<<endl;
- A.ExtractI(2);
- A.Insert(3,'r');
- cout<<"A.Print: ";
- A.Print();//q w e r
- cout<<endl;
- //8.Len
- cout<<"A.Len="<<A.Len()<<endl;
- getch();
- cout<<endl;
- //Массив двунаправленных списков.
- cout<<"Use of class MasOfL2:"<<endl;
- MasOfL2 Mas1(3);
- cout<<"Massive Mas1 was created.Its length equals 3"<<endl;
- //Len
- cout<<"Mas1.Len() returned "<<Mas1.Len()<<endl;
- //PutN
- cout<<"***Mas1.PutN('q w e r',1)"<<endl;
- Mas1.PutN(A,1);//Mas1[1]=q w e r
- //GetN
- cout<<"***Mas1[1]=";
- Mas1.GetN(1).Print();//q w e r
- //operator=
- MasOfL2 Mas2(3);
- Mas2=Mas1;
- cout<<"***Mas2=Mas1"<<endl<<endl<<"***Mas2[1]=";
- Mas2.GetN(1).Print();//q w e r
- cout<<"It's length equals "<<Mas1.GetN(1).Len()<<endl;
- cout<<"***Mas2[2]=";
- Mas2.GetN(2).Print();//empty
- cout<<"It's length equals "<<Mas2.GetN(2).Len()<<endl;
- cout<<"***Mas2[3]=";
- Mas2.GetN(3).Print();//empty
- cout<<"It's length equals "<<Mas2.GetN(3).Len()<<endl;
- //Constructor Copy
- cout<<endl<<endl<<endl;
- Mas2.PutN(B,2);//Mas2[2]=q r w e
- Mas2.PutN(B,3);//Mas2[3]=q r w e
- Mas2.GetN(3).ExtractI(1);//Mas2[3]=r w e
- cout<<"It must be q r w e: ";
- B.Print();//q r w e
- cout<<"it must be r w e: ";
- Mas2.GetN(3).Print();//r w e
- cout<<endl<<endl<<endl;
- // cout<<Mas2.Len()<<endl<<Mas2.GetN(3).Len()<<endl;
- // MasOfL2 Mas3(Mas2);
- // A.Print();//q w e r
- // B.Print();//q r w e
- cout<<"All functions are tested. Demonstration is finished."<<endl;
- 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;
- getch();
- for(int i=0; i<12; i++)
- {
- for(int j=0; j<i; j++)cout<<" ";
- cout<<"Press any key "<<endl;
- }
- cout<<" ";
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement