diff --git a/quick_sort/quick_sort b/quick_sort/quick_sort index d203304..7cb9404 100755 Binary files a/quick_sort/quick_sort and b/quick_sort/quick_sort differ diff --git a/quick_sort/quick_sort.c b/quick_sort/quick_sort.c index 64f20e4..1cbf18d 100644 --- a/quick_sort/quick_sort.c +++ b/quick_sort/quick_sort.c @@ -51,9 +51,13 @@ int right // 右端(※配列の要素数ではない) larger_index--; } - if ( 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] ) { + break; + } + + swap(&array[smaller_index], &array[larger_index]); + + if ( array[smaller_index] == array[larger_index] ) { smaller_index++; } }