Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static char[] qs(char[] items, int left, int right)
- {
- int i, j;
- char x, y;
- i = left; j = right;
- x = items[(left + right) / 2];
- do
- {
- while ((items[i] < x) && (i < right)) i++;
- while ((x < items[j]) && (j > left)) j--;
- if (i <= j)
- {
- y = items[i];
- items[i] = items[j];
- items[j] = y;
- i++; j--;
- }
- } while (i <= j);
- if (left < j)
- {
- return qs(items, left, j);
- }
- if (i < right)
- {
- return qs(items, i, right);
- }
- return //whatever is most appropriate in the case that you arrive here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement