Posted By


kgrlic on 01/19/15

Tagged


Statistics


Viewed 147 times
Favorited by 0 user(s)

main_binarno.cpp


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

test


Copy this code and paste it in your HTML
  1. #include <iostream>
  2. #include "binarno_polje.h"
  3. using namespace std;
  4. int main(){
  5. st_BTREE *tree;
  6. st_ELEM elem;
  7. int unos;
  8. bool dl;
  9. int parent;
  10. int izbor;
  11. do{
  12. cout << "Izbornik:\n0.Ispis\n1.InitT\n2.CreateT\n3.DeleteT\n4.ParentT\n5.LeftChildT\n6.RightChildT\n7.LabelT\n8.RootT\n9.ChangeLabelT\n";
  13. cin >> izbor;
  14. switch(izbor){
  15. case 1:{
  16. cout << "Vrijednost korijena?: ";
  17. cin >> elem.label;
  18. tree = INIT_B(elem.label, tree);
  19. break;
  20. }
  21. case 2:{
  22. cout << "Koliko cvorova unijeti (bez root-a)?: ";
  23. cin >> unos;
  24. do{
  25. cout << "Parent?: ";
  26. cin >> parent;
  27. cout << "Label?: ";
  28. cin >> elem.label;
  29. if(LABEL_B(parent, tree) < elem.label)
  30. CREATE_LEFT_B(elem.label, parent, tree);
  31. if(LABEL_B(parent, tree) > elem.label)
  32. CREATE_RIGHT_B(elem.label, parent, tree);
  33. if(LABEL_B(parent, tree) == elem.label)
  34. continue;
  35. unos--;
  36. }while(unos);
  37. break;
  38. }
  39. case 0:{
  40. cout << "INDEKS\tLABEL\tCHILD\tSIBLING\n";
  41. for(int i = 1; i < ARRAY_SIZE; i++){
  42. if(tree->node[i].used == 0)continue;
  43. cout << i << "\t";
  44. cout << tree->node[i].label << "\t\n";
  45. }
  46. break;
  47. }
  48. case 3:{
  49. int n;
  50. cout << "Koji cvor obrisati (indeks)?: ";
  51. cin >> n;
  52. DELETE_B(n, tree);
  53. break;
  54. }
  55. case 4:{
  56. int n;
  57. cout << "Unesi indeks cvora?: ";
  58. cin >> n;
  59. cout << "tLABEL\tCHILD\tSIBLING\n";
  60. cout << PARENT_B(n, tree) << "\t";
  61. break;
  62. }
  63. case 5:{
  64. int n;
  65. cout << "Unesi indeks cvora?: ";
  66. cin >> n;
  67. cout << "tLABEL\tCHILD\tSIBLING\n";
  68. cout << LEFT_CHILD_B(n, tree) << "\t";
  69. break;
  70. }
  71. case 6:{
  72. int n;
  73. cout << "Unesi indeks cvora?: ";
  74. cin >> n;
  75. cout << "tLABEL\tCHILD\tSIBLING\n";
  76. cout << RIGHT_CHILD_B(n, tree)<< "\t\n";
  77. break;
  78. }
  79. case 7:{
  80. int n;
  81. cout << "Unesi indeks cvora?: ";
  82. cin >> n;
  83. cout << LABEL_B(n, tree) << "\t";
  84. break;
  85. }
  86. case 8:{
  87. cout << "tLABEL\tCHILD\tSIBLING\n";
  88. cout << ROOT_B(tree) << "\t";
  89. break;
  90. }
  91. case 9:{
  92. int x;
  93. int n;
  94. cout << "Unesi indeks cvora?: ";
  95. cin >> n;
  96. cout << "Unesi novi label cvora?: ";
  97. cin >> x;
  98. CHANGE_LABEL_B(x, n, tree);
  99. break;
  100. }
  101. }
  102. }while(izbor != 10);
  103. }

URL: test

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.