#undef MAX_PLAYERS #define MAX_PLAYERS 10 new a[MAX_PLAYERS] = { 90 , 67 , 99 , 11 , 9 , 21 , 58, 0, 47 , 8 }; new b[MAX_PLAYERS];
Sorted: 0 -> ID: 7 Sorted: 8 -> ID: 9 Sorted: 9 -> ID: 4 Sorted: 11 -> ID: 3 Sorted: 21 -> ID: 5 Sorted: 47 -> ID: 8 Sorted: 58 -> ID: 6 Sorted: 67 -> ID: 1 Sorted: 90 -> ID: 2 Sorted: 99 -> ID: 0 |
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)
Sorted: 0 -> ID: 7 Sorted: 8 -> ID: 9 Sorted: 9 -> ID: 4 Sorted: 11 -> ID: 3 Sorted: 21 -> ID: 5 Sorted: 47 -> ID: 8 Sorted: 58 -> ID: 6 Sorted: 67 -> ID: 1 Sorted: 90 -> ID: 2 Sorted: 99 -> ID: 0 |
enum NUMDATA
{
number,
pid
}
for(new i = (sizeof my_array)-1; i > 0; i--)
{
if(my_array[i] >= my_array[i-1]) continue;
my_array[i] ^= (my_array[i-1] ^= (my_array[i] ^= my_array[i-1]));
i = sizeof my_array;
}
for(new i = (sizeof a)-1; i > 0; i--)
{
if(a[i] >= a[i-1]) continue;
a[i] ^= (a[i-1] ^= ( a[i] ^= a[i-1] ) );
i = sizeof a;
printf("%i", i);
}
input(18) : warning 203: symbol is never used: "b" 10 10 10 10 10 10 10 10 10 Error: read EIO (EIO) The server stopped.
my_array[i] ^= (my_array[i-1] ^= (my_array[i] ^= my_array[i-1]));
my_array[i] ^= my_array[i-1];
my_array[i-1] ^= my_array[i];
my_array[i] ^= my_array[i-1];
new array[10][2]; for(new j=0;j<10;j++) { array[j][0] = random(99); // Skill % array[j][1] = j; // playerid } SortDeepArray(array, 0); printf("Sorted \"array\":"); for (new i = 0; i < sizeof(array); i++) { printf(" array[%d] = {%d, %d}", i, array[i][0], array[i][1]); }