Dla tablicy nie za komentowanej działa, dla za komentowanej nie, nie rozumiem w czym jest problem.
#include <stdio.h>
#include <string.h>
void quickSortMain(char items[][10], int count);
void quickSort(char items[][10], int left, int right);
int main(void)
{
int i;
char str[][10] = { "ddd","bbb","ccc","ccc","aaa","aaa" };
//char str[][10] = { "ddd","bbb","ccc","ccc","aaa","aaa","ccc","ddd" };
quickSort(str, 0, 5);
for (i = 0; i<6; i++) {
printf("%s ", str[i]);
}
return 0;
}
void quickSort(char items[][10], int left, int right)
{
int i, j;
char *x;
char temp[10];
if ((strcmp(items[left], items[right]) < 0))
{
x = items[left];
i = left;
j = right;
while (i < j)
{
while ((strcmp(items[i], x) < 0) && (i < right))
{
i++;
}
while (strcmp(items[j], x) > 0)
{
j--;
}
if (i < j)
{
strcpy(temp, items[i]);
strcpy(items[i], items[j]);
strcpy(items[j], temp);
}
}
strcpy(temp, x);
strcpy(x, items[j]);
strcpy(items[j], temp);
quickSort(items, left, j - 1);
quickSort(items, j + 1, right);
}
}