Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Drzewo::odejmijLisc(int Wartosc_do_usuniecia)
- {
- Lisc *temp = pierwszy;
- while(1)
- {
- {
- if (temp->wartosc > Wartosc_do_usuniecia)
- {
- if (temp->lewy->wartosc == Wartosc_do_usuniecia)
- {
- Lisc *liscDoUsuniecia = temp->lewy;
- Lisc *tempLewy = temp->lewy->lewy;
- if (temp->lewy->prawy != 0)
- {
- temp->lewy = temp->lewy->prawy;
- }
- else
- {
- if (temp->lewy->lewy != 0)
- {
- temp->lewy = temp->lewy->lewy;
- break;
- }
- else
- {
- temp->lewy = 0;
- break;
- }
- }
- if (tempLewy != 0)
- {
- while (temp->lewy != 0)
- {
- temp = temp->lewy;
- }
- temp->lewy = tempLewy;
- }
- else
- {
- temp->lewy->lewy = 0;
- }
- delete liscDoUsuniecia;
- break;
- }
- temp = temp->lewy;
- }
- if(temp->wartosc <Wartosc_do_usuniecia)
- {
- if(temp->prawy->wartosc == Wartosc_do_usuniecia)
- {
- Lisc *tempLewy2 = temp->prawy->lewy;
- Lisc *liscDoUsuniecia = temp->prawy;
- if (temp->lewy->prawy != 0)
- {
- temp->prawy = temp->prawy->prawy;
- }
- else
- {
- if (temp->prawy->lewy != 0)
- {
- temp->prawy = temp->prawy->lewy;
- break;
- }
- else
- {
- temp->prawy = 0;
- break;
- }
- }
- if (tempLewy2 != 0)
- {
- temp = temp->prawy;
- while (temp->lewy != 0)
- {
- temp = temp->lewy;
- }
- temp->lewy = tempLewy2;
- break;
- }
- else
- {
- temp->prawy->lewy = 0;
- }
- delete liscDoUsuniecia;
- break;
- }
- temp = temp->prawy;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment