Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. int main()
  2. {
  3. Produkt *root_l= new Produkt();
  4.  
  5.  
  6. for(int i=0; i<49; i++)
  7. {
  8. Produkt * nowy=new Produkt();
  9.  
  10.  
  11. //E<eby sortowaD roota
  12. if(nowy->return_numer()< root_l->return_numer())
  13. {
  14. nowy->next=root_l;
  15. root_l =nowy;
  16. }
  17. else root_l->wstaw_l(nowy);
  18. }
  19. root_l->wyswietl_l();
  20.  
  21.  
  22. /*
  23. //przenoszenie wszystkoch elementC3w z listy do drzewa
  24.  
  25.  
  26. Produkt * root_d=root_l;
  27. root_l=root_l->next;
  28. root_d->next=NULL;
  29. while(root_l)
  30. {
  31. Produkt *pom=root_l;
  32. root_l=root_l->next;
  33. pom->next=NULL;
  34. root_d->wstaw_d(pom);
  35. }
  36.  
  37.  
  38. */
  39.  
  40.  
  41.  
  42.  
  43. //warunek kiedy root_d jest nieparzysty
  44. //ustawienie root_d na pierwszy obiekt na liEcie
  45. Produkt *root_d=root_l;
  46. Produkt *pom=root_l;
  47.  
  48.  
  49. //1
  50. root_d=root_l;
  51. if(root_d->return_cena()>80)
  52. {
  53. root_l=root_l->next;
  54. root_d->next=NULL;
  55.  
  56.  
  57. while(root_l->return_cena()>80)
  58. {
  59. Produkt *pom=root_l;
  60. root_l=root_l->next;
  61. pom->next=NULL;
  62. root_d->wstaw_d(pom);
  63. }
  64. pom=root_l;
  65.  
  66.  
  67. while (pom->next)
  68. {
  69. if(pom->next->return_cena()>80)
  70. {
  71. Produkt *pom2=pom->next;
  72. pom->next=pom2->next;
  73. pom2->next=NULL;
  74. root_d->wstaw_d(pom2);
  75. }
  76. else pom=pom->next;
  77. }
  78. }
  79. else{
  80. while(root_d->return_cena()<=80 )//dopC3ki root_drzewa jest nieparzysty
  81. {
  82. if(pom->next->return_cena()>80)
  83. {
  84. root_d=pom->next;
  85. pom->next=root_d->next;
  86. root_d->next=NULL;
  87. }
  88. else pom=pom->next;
  89. }
  90. pom=root_l;
  91.  
  92.  
  93. while (pom->next)
  94. {
  95. if(pom->next->return_cena()>80)
  96. {
  97. Produkt *pom2=pom->next;
  98. pom->next=pom2->next;
  99. pom2->next=NULL;
  100. root_d->wstaw_d(pom2);
  101. }
  102. else pom=pom->next;
  103. }
  104. }
  105. cout << "LISTA PO USUNIECIU: " << endl;
  106. root_l->wyswietl_l();
  107. cout << "DRZEWO" << endl;
  108. root_d->wyswietl_d();
  109. return 0;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement