Advertisement
Danielos168

Zadanie 5 ( ścieżka)

Nov 21st, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. static char[] qs(char[] items, int left, int right)
  2.     {
  3.         int i, j;
  4.         char x, y;
  5.  
  6.         i = left; j = right;
  7.         x = items[(left + right) / 2];
  8.  
  9.         do
  10.         {
  11.             while ((items[i] < x) && (i < right)) i++;
  12.             while ((x < items[j]) && (j > left)) j--;
  13.  
  14.             if (i <= j)
  15.             {
  16.                 y = items[i];
  17.                 items[i] = items[j];
  18.                 items[j] = y;
  19.                 i++; j--;
  20.             }
  21.         } while (i <= j);
  22.  
  23.         if (left < j)
  24.         {
  25.             return qs(items, left, j);
  26.         }
  27.         if (i < right)
  28.         {
  29.             return qs(items, i, right);
  30.         }
  31.         return //whatever is most appropriate in the case that you arrive here
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement