fix: quick sort

This commit is contained in:
kemasama 2022-04-27 18:32:13 +09:00
parent 511de8b71f
commit a0c8b41fbc
2 changed files with 7 additions and 3 deletions

Binary file not shown.

View File

@ -51,9 +51,13 @@ int right // 右端(※配列の要素数ではない)
larger_index--; larger_index--;
} }
if ( array[smaller_index] > array[larger_index] ) { if ( array[smaller_index] < array[larger_index] ) {
break;
}
swap(&array[smaller_index], &array[larger_index]); swap(&array[smaller_index], &array[larger_index]);
} else if ( array[smaller_index] == array[larger_index] ) {
if ( array[smaller_index] == array[larger_index] ) {
smaller_index++; smaller_index++;
} }
} }