Test za b i c zadatak


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #include <iostream>
  2. #include <sstream>
  3. //#include "b.h"
  4. #include "c.h"
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. btree drvce;
  10.  
  11. InitB("korijen", &drvce);
  12. cout << "*******STVARANJE DJECE KORIJENA*******" << endl;
  13. CreateLeftB("1", RootB(&drvce), &drvce);
  14. CreateRightB("2", RootB(&drvce), &drvce);
  15.  
  16. cout << "*******PROVJERA FUNKCIJA Lleft/RightChildB*******" << endl;
  17. node n1 = LeftChildB(RootB(&drvce), &drvce);
  18. node n2 = RightChildB(RootB(&drvce), &drvce);
  19. cout << "*******STVARANJE UNUKA KORIJENA*******" << endl;
  20.  
  21. CreateLeftB("3", n1, &drvce);
  22. CreateRightB("4", n1, &drvce);
  23.  
  24. CreateLeftB("6", n2, &drvce);
  25. CreateRightB("7", n2, &drvce);
  26. cout << "******* ISPISIVANJE LABEL-A SVIH CVOROVA *******" << endl;
  27. cout << LabelB(RootB(&drvce), &drvce) << endl;
  28. cout << LabelB(n1, &drvce) << endl;
  29. cout << LabelB(n2, &drvce) << endl;
  30. cout << LabelB(LeftChildB(n1, &drvce), &drvce) << endl;
  31. cout << LabelB(RightChildB(n1, &drvce), &drvce) << endl;
  32. cout << LabelB(LeftChildB(n2, &drvce), &drvce) << endl;
  33. cout << LabelB(RightChildB(n2, &drvce), &drvce) << endl;
  34.  
  35. cout << "******* TEST ParentB FUNKCIJE *******" << endl;
  36. cout << "Roditelj cvora n1 (oznaka 1) ima oznaku: " << LabelB(ParentB(n1, &drvce), &drvce) << endl;
  37. cout << "Roditelj cvora n2 (oznaka 2) ima oznaku: " << LabelB(ParentB(n2, &drvce), &drvce) << endl;
  38.  
  39. cout << "******* TESTIRANJE BRISANJA CVOROVA *******" << endl;
  40. cout << "n1 i njegovo lijevo dijete su: ";
  41.  
  42. if (LeftChildB(RootB(&drvce), &drvce) && LeftChildB(n1, &drvce)) {
  43. cout << "zivi i zdravi." << endl;
  44. }
  45. else {
  46. cout << "obrisani!" << endl;
  47. }
  48.  
  49. DeleteB(n1, &drvce);
  50. cout << "n1 i njegovo lijevo dijete su: ";
  51.  
  52. if (LeftChildB(RootB(&drvce), &drvce) || LeftChildB(n1, &drvce)) {
  53. cout << "zivi i zdravi." << endl;
  54. }
  55. else {
  56. cout << "obrisani!" << endl;
  57. }
  58. cout << "******* ISPIT ChangeLabelB FUNKCIJE *******" << endl;
  59. ChangeLabelB("Volim strukture podataka.", RootB(&drvce), &drvce);
  60. cout << LabelB(RootB(&drvce), &drvce) << endl;
  61. cout << "I to zavrsava nas test!" << endl;
  62.  
  63. return 0;
  64. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.