Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //#include "ostablo.h"
- //#include "bstablo_polje.h"
- #include "bstablo_pokazivac.h"
- using namespace std;
- void opcenito_stablo()
- {/*
- tr T;
- InitT(9, T);
- T.el[0].vrij = 'F';
- T.el[0].c = -1;
- T.el[0].b = 6;
- T.el[1].vrij = 'E';
- T.el[1].c = -1;
- T.el[1].b = -1;
- T.el[2].vrij = 'D';
- T.el[2].c = 0;
- T.el[2].b = -1;
- T.el[3].vrij = 'H';
- T.el[3].c = -1;
- T.el[3].b = -1;
- T.el[4].vrij = 'B';
- T.el[4].c = 2;
- T.el[4].b = 10;
- T.el[6].vrij = 'G';
- T.el[6].c = -1;
- T.el[6].b = 3;
- T.el[9].vrij = 'A';
- T.el[9].c = 4;
- T.el[9].b = -1;
- T.el[10].vrij = 'C';
- T.el[10].c = 1;
- T.el[10].b = -1;
- cout << "FirstChildT(2, T): " << FirstChildT(2, T) << endl;
- cout << "FirstChildT(6, T): " << FirstChildT(6, T) << endl;
- cout << "NextSiblingT(6, T): " << NextSiblingT(6, T) << endl;
- cout << "NextSiblingT(1, T): " << NextSiblingT(1, T) << endl;
- cout << "ParentT(6, T): " << ParentT(6, T) << endl;
- cout << "ParentT(9, T): " << ParentT(9, T) << endl;
- cout << "LabelT(6, T): " << LabelT(6, T) << endl;
- cout << "ChangeLabelT('L', 6, T)" << endl;
- ChangeLabelT('L', 6, T);
- cout << "LabelT(6, T): " << LabelT(6, T) << endl;
- cout << "RootT(T): " << RootT(T) << endl;
- cout << "CreateT('Z', 10, T): " << endl;
- CreateT('Z', 10, T);
- cout << "NextSiblingT(1, T): " << NextSiblingT(1, T) << endl;
- cout << "DeleteT(4, T): " << endl;
- DeleteT(4, T);
- cout << "FirstChildT(RootT(T), T): " << FirstChildT(RootT(T), T) << endl;*/
- }
- void binarno_stablo_polje()
- {/*
- bt T;
- InitB(1, T);
- cout << CreateLeftB(2, 1, T) << endl;
- cout << CreateRightB(3, 1, T) << endl;
- cout << CreateRightB(4, 2, T) << endl;
- cout << CreateLeftB(5, 3, T) << endl;
- cout << CreateLeftB(6, 5, T) << endl;
- cout << CreateRightB(7, 5, T) << endl;
- cout << CreateRightB(8, 6, T) << endl;
- cout << "-------------------\n";
- cout << "ParentB(6, T): " << ParentB(6, T) << endl;
- cout << "LeftChildB(6, T): " << LeftChildB(6, T) << endl;
- cout << "RightChildB(6, T): " << RightChildB(6, T) << endl;
- cout << "LabelB(6, T): " << LabelB(6, T) << endl;
- cout << "ChangeLabelB(2, 6, T): " << ChangeLabelB(2, 6, T) << endl;
- cout << "LabelB(6, T): " << LabelB(6, T) << endl;
- cout << "RootB(T): " << RootB(T) << endl;
- cout << "CreateLeftB(5,6,T): " << CreateLeftB(5,6,T) << endl;
- cout << "LeftChildB(6, T): " << LeftChildB(6, T) << endl;
- cout << "CreateRightB(5,6,T): " << CreateRightB(5,6,T) << endl;
- system("pause");
- cout << "-------------------\n";
- DeleteB(3,T);
- for(int i = 1; i < 14; i++)
- cout << i << ": " << LabelB(i, T) << endl;
- system("pause");
- cout << "-------------------\n";
- InitB(2, T);
- for(int i = 1; i < 14; i++)
- cout << i << ": " << LabelB(i, T) << endl;
- */
- }
- void tab(int t)
- {
- for(int i = 0; i < t; i++)
- cout << " ";
- }
- void Ispis(bTree *node, int t)
- {
- tab(t);
- cout << "--------------------------------------\n";
- tab(t);
- cout << "Adresa: " << node << "\n";
- tab(t);
- cout << "Label: " << LabelB(node) << "\n";
- tab(t);
- cout << "Left: " << LeftChildB(node) << "\n";
- if(LeftChildB(node)) Ispis(LeftChildB(node), t+1);
- tab(t);
- cout << "Right: " << RightChildB(node) << "\n";
- if(RightChildB(node)) Ispis(RightChildB(node), t+1);
- tab(t);
- cout << "--------------------------------------\n";
- }
- void binarno_stablo_pok()
- {
- bTree *T = InitB(1);
- cout << CreateLeftB(2, T) << endl;
- cout << CreateRightB(3, T) << endl;
- cout << CreateRightB(4, T->l) << endl;
- cout << CreateLeftB(5, T->r) << endl;
- cout << CreateLeftB(6, T->l->r) << endl;
- cout << CreateRightB(7, T->l->r) << endl;
- cout << CreateRightB(8, T->r->l) << endl;
- system("pause");
- Ispis(T, 0);
- system("pause");
- cout << "\nParentB(*8, T): " << ParentB(T->r->l->r, T);
- cout << "\nLeftChildB(*5, T): " << LeftChildB(T->r->l);
- cout << "\nRightChildB(*5, T): " << RightChildB(T->r->l);
- cout << "\nLabelB(*5, T): " << LabelB(T->r->l);
- cout << "\nChangeLabelB(3, *5, T)";
- ChangeLabelB(3, T->r->l);
- cout << "\nLabelB(*5, T): " << LabelB(T->r->l);
- cout << "\nRootB(T): " << RootB(T);
- cout << "\nDeleteB(*3, T)\n";
- DeleteB(T->r, T);
- Ispis(T, 0);
- DeleteB(T, T);
- }
- int main()
- {
- //opcenito_stablo();
- //binarno_stablo_polje();
- binarno_stablo_pok();
- cout << "\n";
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment