Posted By

kgrlic on 01/21/15


Tagged

test


Versions (?)

main.cpp


 / Published in: C++
 

URL: test

test

  1. #include <iostream>
  2. #include "stablo_polje.h"
  3. using namespace std;
  4. int main(){
  5. st_TREE *tree;
  6. st_ELEM elem;
  7. int unos;
  8. char parent;
  9. int izbor;
  10. do{
  11. cout << "Izbornik:\n0.Ispis\n1.InitT\n2.CreateT\n3.DeleteT\n4.ParentT\n5.FirstChildT\n6.NextSiblingT\n7.LabelT\n8.RootT\n9.ChangeLabelT\n10.Preorder\n11.Inorder\n12.Postorder\n13.Izlaz\n";
  12. cin >> izbor;
  13. switch(izbor){
  14. case 1:{
  15. elem.label = 'A';
  16. elem.FIRST_CHILD = -1;
  17. elem.NEXT_SIBLING = -1;
  18. tree = INIT_T(elem, 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. CREATE_T(elem, parent, tree);
  30. unos--;
  31. }while(unos);
  32. break;
  33. }
  34. case 0:{
  35. cout << "INDEKS\tLABEL\tCHILD\tSIBLING\n";
  36. int i = 0;
  37. for(int i = 0; i < ARRAY_SIZE; i++){
  38. if(tree->node[i].label == '-')continue;
  39. cout << i << "\t";
  40. cout << tree->node[i].label << "\t";
  41. cout << tree->node[i].FIRST_CHILD << "\t";
  42. cout << tree->node[i].NEXT_SIBLING<< "\t\n";
  43. }
  44. break;
  45. }
  46. case 3:{
  47. int n;
  48. cout << "Koji cvor obrisati (indeks)?: ";
  49. cin >> n;
  50. DELETE_T(n, tree);
  51. break;
  52. }
  53. case 4:{
  54. char n;
  55. cout << "Unesi cvor?: ";
  56. cin >> n;
  57. cout << "tLABEL\tCHILD\tSIBLING\n";
  58. cout << PARENT_T(n, tree).label << "\t";
  59. cout << PARENT_T(n, tree).FIRST_CHILD << "\t";
  60. cout << PARENT_T(n, tree).NEXT_SIBLING<< "\t\n";
  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 << FIRST_CHILD_T(n, tree).label << "\t";
  69. cout << FIRST_CHILD_T(n, tree).FIRST_CHILD << "\t";
  70. cout << FIRST_CHILD_T(n, tree).NEXT_SIBLING<< "\t\n";
  71. break;
  72. break;
  73. }
  74. case 6:{
  75. int n;
  76. cout << "Unesi indeks cvora?: ";
  77. cin >> n;
  78. cout << "tLABEL\tCHILD\tSIBLING\n";
  79. cout << NEXT_SIBLING_T(n, tree).label << "\t";
  80. cout << NEXT_SIBLING_T(n, tree).FIRST_CHILD << "\t";
  81. cout << NEXT_SIBLING_T(n, tree).NEXT_SIBLING<< "\t\n";
  82. break;
  83. }
  84. case 7:{
  85. int n;
  86. cout << "Unesi indeks cvora?: ";
  87. cin >> n;
  88. cout << LABEL_T(n, tree) << "\t";
  89. break;
  90. }
  91. case 8:{
  92. cout << "tLABEL\tCHILD\tSIBLING\n";
  93. cout << ROOT_T(tree).label << "\t";
  94. cout << ROOT_T(tree).FIRST_CHILD << "\t";
  95. cout << ROOT_T(tree).NEXT_SIBLING<< "\t\n";
  96. break;
  97. }
  98. case 9:{
  99. char x;
  100. int n;
  101. cout << "Unesi indeks cvora?: ";
  102. cin >> n;
  103. cout << "Unesi novi label cvora?: ";
  104. cin >> x;
  105. CHANGE_LABEL_T(x, n, tree);
  106. break;
  107. }
  108. case 10:{
  109. PREORDER(tree);
  110. break;
  111. }
  112. case 11:{
  113. INORDER(tree);
  114. break;
  115. }
  116. case 12:{
  117. POSTORDER(tree);
  118. break;
  119. }
  120. }
  121. }while(izbor != 13);
  122. }

Report this snippet  

You need to login to post a comment.