23.12.2013, 15:44
I don't really get what you mean, but I came up with something, thanks to Ryder for his quickSort function.
Code
Result/Output
Code
pawn Код:
new a[MAX_PLAYERS] = { 90 , 67 , 99 , 11 , 9 , 21 , 58, 0, 47 , 8 };
new b[MAX_PLAYERS];
main()
{
quickSort(a, 0, sizeof(a) - 1);
new
i = 0;
while(i != sizeof(a))
{
printf("%d", a[i]);
i++;
}
}
stock quickSort(array[], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2],
tempVar
;
while(tempLeft <= tempRight)
{
while(array[tempLeft] < pivot) tempLeft++;
while(array[tempRight] > pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft], array[tempLeft] = array[tempRight], array[tempRight] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) quickSort(array, left, tempRight);
if(tempLeft < right) quickSort(array, tempLeft, right);
}
Код:
input(42) : warning 203: symbol is never used: "b" 0 8 9 11 21 47 58 67 90 99 Error: read EIO (EIO)