|
Реализация списка
Iaiaoiaeii ?aaeeciaaou nienie aeaa: Oaoie?aneia iienaiea i?ia?aiiu. Nicaaiea
iiaiai aienea; Nio?aiaiea aaiiuo nienea a oaee; Iiene
yeaiaioa a nienea; Aey ?aaiou n oaeeii iaiaoiaeii ia niioaaonoao?uee cai?in i?ia?aiiu
aaanoe eiy oaeea, ec eioi?iai aoaoo acyou aaiiua aey iino?iaiey nienea. ?aaiou i?ia?aiiu o?aaoaony PC niaianoeiue eiiiu?oa? e
eiiieeyoi? Borland 3.01 e auoa. I?e eniieuciaaiea eiiai ni?aoay oa?aeoa?enoee
nenoaiu ia eioi?ie aoaao oanoe?iaaouny i?ia?aiia aicii?iu iaeioi?ua ?anoi?aaiey
n ?acoeuoaoaie oanoa, ii a iniiaiii ie?aai no?aoiiai i?iecieoe ia
aie?ii. {struct Tree ~Tree() {Body=0; LP=NULL; RP=NULL;} List::List(int
Digit) PTree->LP=NULL; {if (PTree1-
>LP!=NULL) } int Mass; int
AddElements(); int SubWork(int
Task); void GoThroughTree(Tree *L); {cout<<endl<<"Main
Menu:"<<endl<<endl; cout<<"
3. Print List." <<endl;
cout<<" 6. Erase List." <<endl; cout<<"
9. Sort List." <<endl; {cin>>i; } cout<<"1. Sort list
by increase."<<endl;
do while (i<1 i>2); {case 1 : SortByIncrease();
break; //Increase {switch (Task) case 2 :
ElementQuantity+=AddElements(); break; //Add Element case
5 : SaveList(); break; //Save List case 8 :
FindElement(); break; //Find Element
} int TreeWork::MakeNewList() cout<<endl<<"Input quantity of elements: "; while (Quant<1);
PList=new List(Digit); {List
*PList1=BegP->LPrev; PList->LPrev=BegP; PList->LPrev=PList1; {MakeNewList(); return 0;} if (Quant<1)
{cout<<endl<<"Input digit: ";
{BegP->LNext=PList; {BegP-
>LPrev=PList; return Quant; {cout<<endl<<"The list
is empty!"<<endl; return -1;}
{cout<<endl<<" "<<i<<" element: "<<endl; return 0; PL=PL->LP; if
(PL->RP!=NULL) GoThroughTree(PL);} if (PL->RP!=NULL) {if (BegP!=NULL) PList-
>LPrev=BegP; int
TreeWork::DeleteElement() if (Number>ElementQuantity
Number<0) PList=PList->LNext; PList2->LNext=PList1;
PList1=NULL; PList2=NULL;} delete []
PList; {cout<<endl<<"Input number, you
want to find: "; if (Number>PT->Body && Number<PT-
>Body+10) PList=NULL;
cout<<endl; return 0;} cout<<endl<<"There aren't such number in
list!"<<endl; if(BegP==NULL)
{cout<<endl<<"Error!"<<endl; return -1;} {Tree *PT; } int TreeWork::SortByDecrease() List *PList1=BegP;
PList=BegP; PList1->Root=PList-
>Root; }
{cout<<endl<<"The list is empty!"<<endl; return -1;} cout<<endl<<"Input
file name: "; cin>>FileName; if
(PList!=BegP) delete [] FileName;
{cout<<endl<<"The list is alredy exist!"<<endl; return -1;} ifstream f;
f>>Mass; PList=NULL;} PList->LNext=BegP; PList->LNext=BegP; f.close(); ?acoeuoaou ?aaiou i?ia?aiiu. 4. Delete Element. Your choice : 1. Make New List. 8. Find Element. Aaiaei eiee?anoai
yeaiaioia a nienea (i?aaiiei?ei 4): 1. Make New
List. 8. Find Element. Input digit: 4 6. Erase
List. Iinea aaiaa nienea iiiaaaai a aeaaiia iai? aaa
auae?aai ioieo aiaaaeaiey yeaiaioa : Input
digit: 2 4. Delete Element. Your choice : 2 I?ia?aiia i?ineo aaanoe eiee?anoai yeaiaioia
eioi?ia iu oioei aiaaaeo e iaoaio nieneo. Aaiaei 1 (aey i?eia?a): Input digit: 3 5. Save List. Input kol-vo of elements: 1 Iinea oaa?iiai caaa?oaiey aiaaaeaiey yeaiaioa a nienie iu aiiau iiiaaaai
a aeaaiia iai?, aaa auae?aai ioieo auaiaa nienea ia ye?ai iiieoi?a: 2 element: 2345 3. Print
List. 0. Exit. Auno?i i?ineieucioa ieii Aaoeo aeac iaiiiyoiua aaiiua
au niiaa iiiaaaaoa a aeaaiia iai?, aaa auae?aaoa ioieo oaaeaiea yeaiaioa: 3 element: 3456 4. Delete Element. Your choice : 4 Iinea ?aai yeaiaio n aaaa?iiui
iiia?ii oaaeai. Iinea oaa?iiai caaa?oaiey oaaeaiey yeaiaioa Au niiaa iiiaaaaoa a
aeaaiia iai?, aaa auae?aaoa ioieo nio?aiaiea nienea: 1. Make
New List. 8. Find Element. Iinea aaiaa eiaie oaeea aaiiua ec nienea
iiiaaa?o ia aene. E au niiaa a aeaaiii iai?, aaa auae?aaoa oaaeaiea nienea: 6. Erase List. Main Menu: 7. Open
File. Iinea ?aai ana aaiiua a nienea aacaica?aoii oie?a?o e
Au iiyou o aeaaiiai nienea, e auae?aaoa Au – ioe?uou oaee: 6. Erase List. 1. Make New List. 8. Find Element. Iinea ?aai aao
nienie i?eaaao e … ia iaai "e" - eo?oa i?iaie?ei – Au a aeaaiii iai? e Au
auae?aaoa iaeoe yeaiaio:
2. Add Element. 9. Sort List. Au aaiaeoa oi ?oi oioaee iaeoe
e – iaoiaeoa a no?i?ea OOOOO. Aeaaiia iai?/Ni?oe?iaea: 1. Make New List. 8. Find
Element. Your
choice: Oo iu ii?ai ni?oe?iaaou ii aic?anoaie? eee oauaaie?
(aaau o ?aeiaaea anaaaa aie?ai auou auai?!). Iinea ni?oe?iaee Aeaaiia
iai?/Auoia! An? i?ia?aiia caaa?oeeanu oniaoii! A iineieueo yoe oanou ieeoi ia
?eoaao, oi ii?ii neacaou ?oi eiiiu?oa?u a iaoai einoeoooa naaeaiu ec
aoaa.
| |