Pi0trek

Untitled

Oct 5th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. void Drzewo::odejmijLisc(int Wartosc_do_usuniecia)
  2. {
  3.     Lisc *temp = pierwszy;
  4.     while(1)
  5.     {
  6.         {
  7.             if (temp->wartosc > Wartosc_do_usuniecia)
  8.             {
  9.                 if (temp->lewy->wartosc == Wartosc_do_usuniecia)
  10.                 {
  11.                     Lisc *liscDoUsuniecia = temp->lewy;
  12.                     Lisc *tempLewy = temp->lewy->lewy;
  13.  
  14.                     if (temp->lewy->prawy != 0)
  15.                     {
  16.                         temp->lewy = temp->lewy->prawy;
  17.                     }
  18.                     else
  19.                     {
  20.                         if (temp->lewy->lewy != 0)
  21.                         {
  22.                             temp->lewy = temp->lewy->lewy;
  23.                             break;
  24.                         }
  25.                         else
  26.                         {
  27.                             temp->lewy = 0;
  28.                             break;
  29.                         }
  30.                     }
  31.  
  32.                     if (tempLewy != 0)
  33.                     {
  34.                        
  35.                         while (temp->lewy != 0)
  36.                         {
  37.                             temp = temp->lewy;
  38.                         }
  39.                         temp->lewy = tempLewy;
  40.                     }
  41.                     else
  42.                     {
  43.                         temp->lewy->lewy = 0;
  44.                     }
  45.  
  46.                 delete liscDoUsuniecia;
  47.                 break;                                     
  48.                 }
  49.  
  50.                 temp = temp->lewy;
  51.  
  52.             }
  53.  
  54.             if(temp->wartosc <Wartosc_do_usuniecia)
  55.             {
  56.                 if(temp->prawy->wartosc == Wartosc_do_usuniecia)
  57.                 {
  58.                     Lisc *tempLewy2 = temp->prawy->lewy;
  59.                     Lisc *liscDoUsuniecia = temp->prawy;
  60.  
  61.                     if (temp->lewy->prawy != 0)
  62.                     {
  63.                         temp->prawy = temp->prawy->prawy;
  64.                     }
  65.                     else
  66.                     {
  67.                         if (temp->prawy->lewy != 0)
  68.                         {
  69.                             temp->prawy = temp->prawy->lewy;
  70.                             break;
  71.                         }
  72.                         else
  73.                         {
  74.                             temp->prawy = 0;
  75.                             break;
  76.                         }
  77.                     }
  78.                     if (tempLewy2 != 0)
  79.                     {
  80.                         temp = temp->prawy;
  81.                         while (temp->lewy != 0)
  82.                         {
  83.                             temp = temp->lewy;
  84.                         }
  85.  
  86.                         temp->lewy = tempLewy2;
  87.                         break;
  88.                     }
  89.                     else
  90.                     {
  91.                         temp->prawy->lewy = 0;
  92.                     }
  93.                     delete liscDoUsuniecia;
  94.                     break;
  95.                 }
  96.                 temp = temp->prawy;
  97.             }
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment