Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- Produkt *root_l= new Produkt();
- for(int i=0; i<49; i++)
- {
- Produkt * nowy=new Produkt();
- //E<eby sortowaD roota
- if(nowy->return_numer()< root_l->return_numer())
- {
- nowy->next=root_l;
- root_l =nowy;
- }
- else root_l->wstaw_l(nowy);
- }
- root_l->wyswietl_l();
- /*
- //przenoszenie wszystkoch elementC3w z listy do drzewa
- Produkt * root_d=root_l;
- root_l=root_l->next;
- root_d->next=NULL;
- while(root_l)
- {
- Produkt *pom=root_l;
- root_l=root_l->next;
- pom->next=NULL;
- root_d->wstaw_d(pom);
- }
- */
- //warunek kiedy root_d jest nieparzysty
- //ustawienie root_d na pierwszy obiekt na liEcie
- Produkt *root_d=root_l;
- Produkt *pom=root_l;
- //1
- root_d=root_l;
- if(root_d->return_cena()>80)
- {
- root_l=root_l->next;
- root_d->next=NULL;
- while(root_l->return_cena()>80)
- {
- Produkt *pom=root_l;
- root_l=root_l->next;
- pom->next=NULL;
- root_d->wstaw_d(pom);
- }
- pom=root_l;
- while (pom->next)
- {
- if(pom->next->return_cena()>80)
- {
- Produkt *pom2=pom->next;
- pom->next=pom2->next;
- pom2->next=NULL;
- root_d->wstaw_d(pom2);
- }
- else pom=pom->next;
- }
- }
- else{
- while(root_d->return_cena()<=80 )//dopC3ki root_drzewa jest nieparzysty
- {
- if(pom->next->return_cena()>80)
- {
- root_d=pom->next;
- pom->next=root_d->next;
- root_d->next=NULL;
- }
- else pom=pom->next;
- }
- pom=root_l;
- while (pom->next)
- {
- if(pom->next->return_cena()>80)
- {
- Produkt *pom2=pom->next;
- pom->next=pom2->next;
- pom2->next=NULL;
- root_d->wstaw_d(pom2);
- }
- else pom=pom->next;
- }
- }
- cout << "LISTA PO USUNIECIU: " << endl;
- root_l->wyswietl_l();
- cout << "DRZEWO" << endl;
- root_d->wyswietl_d();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement