Реферат: Программирование на С++

#include


class List

{struct Tree

{int Body;

Tree *LP;

Tree *RP;

Tree(int Bdy=0) {Body=Bdy; LP=NULL; RP=NULL;}

~Tree() {Body=0; LP=NULL; RP=NULL;}

};

public:

List(int Digit=0);

Tree *Root;

List *LNext;

List *LPrev;

};


List::List(int Digit)

{Root=NULL;

for (int i=Digit*10; i

{Tree *PTree;

PTree=new Tree(i);

PTree->LP=NULL;

PTree->RP=NULL;

if (Root==NULL)

Root=PTree;

else

{Tree *PTree1=Root;

do

{if (PTree1->LP!=NULL)

PTree1=PTree1->LP;}

while (PTree1->LP!=NULL);

PTree1->LP=PTree;

PTree=NULL; PTree1=NULL;

}

}

}


class TreeWork : private List

{public:

void TreeWorkStart();

private:

int ElementQuantity;

int Mass;

int i;

List *BegP;

List *PList;

int MainMenu();

int Work(int Task);

int MakeNewList();

int AddElements();

int PrintList();

void EraseList();

int DeleteElement();

int FindElement();

int SubMenu();

int SubWork(int Task);

int SortByIncrease();

int SortByDecrease();

int SaveList();

int OpenList();

protected:

void GoThroughTree(Tree *L);

void Erase(Tree *L);

};


int TreeWork::MainMenu()

{cout<

cout<<" 1. Make New List." <

cout<<" 2. Add Element." <

cout<<" 3. Print List." <

cout<<" 4. Delete Element."<

cout<<" 5. Save List." <

cout<<" 6. Erase List." <

cout<<" 7. Open File." <

cout<<" 8. Find Element." <

cout<<" 9. Sort List." <

cout<<" 0. Exit." <

cout<

int i;

do

{cin>>i;

if (i<0 || i>9) cout<

}

while (i<0 || i>9);

return i;

}


int TreeWork::SubMenu()

{cout<

cout<<"1. Sort list by increase."<

cout<<"2. Sort list by decrease."<

int i;

cout<<"Your choice: ";

do

{cin>>i;

if (i<1 || i>2) cout<

}

while (i<1 || i>2);

К-во Просмотров: 1158
Бесплатно скачать Реферат: Программирование на С++