/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> #include <sstream> //#include "b.h" #include "c.h" using namespace std; int main() { btree drvce; InitB("korijen", &drvce); cout << "*******STVARANJE DJECE KORIJENA*******" << endl; CreateLeftB("1", RootB(&drvce), &drvce); CreateRightB("2", RootB(&drvce), &drvce); cout << "*******PROVJERA FUNKCIJA Lleft/RightChildB*******" << endl; node n1 = LeftChildB(RootB(&drvce), &drvce); node n2 = RightChildB(RootB(&drvce), &drvce); cout << "*******STVARANJE UNUKA KORIJENA*******" << endl; CreateLeftB("3", n1, &drvce); CreateRightB("4", n1, &drvce); CreateLeftB("6", n2, &drvce); CreateRightB("7", n2, &drvce); cout << "******* ISPISIVANJE LABEL-A SVIH CVOROVA *******" << endl; cout << LabelB(RootB(&drvce), &drvce) << endl; cout << LabelB(n1, &drvce) << endl; cout << LabelB(n2, &drvce) << endl; cout << LabelB(LeftChildB(n1, &drvce), &drvce) << endl; cout << LabelB(RightChildB(n1, &drvce), &drvce) << endl; cout << LabelB(LeftChildB(n2, &drvce), &drvce) << endl; cout << LabelB(RightChildB(n2, &drvce), &drvce) << endl; cout << "******* TEST ParentB FUNKCIJE *******" << endl; cout << "Roditelj cvora n1 (oznaka 1) ima oznaku: " << LabelB(ParentB(n1, &drvce), &drvce) << endl; cout << "Roditelj cvora n2 (oznaka 2) ima oznaku: " << LabelB(ParentB(n2, &drvce), &drvce) << endl; cout << "******* TESTIRANJE BRISANJA CVOROVA *******" << endl; cout << "n1 i njegovo lijevo dijete su: "; if (LeftChildB(RootB(&drvce), &drvce) && LeftChildB(n1, &drvce)) { cout << "zivi i zdravi." << endl; } else { cout << "obrisani!" << endl; } DeleteB(n1, &drvce); cout << "n1 i njegovo lijevo dijete su: "; if (LeftChildB(RootB(&drvce), &drvce) || LeftChildB(n1, &drvce)) { cout << "zivi i zdravi." << endl; } else { cout << "obrisani!" << endl; } cout << "******* ISPIT ChangeLabelB FUNKCIJE *******" << endl; ChangeLabelB("Volim strukture podataka.", RootB(&drvce), &drvce); cout << LabelB(RootB(&drvce), &drvce) << endl; cout << "I to zavrsava nas test!" << endl; return 0; }