def qsort(s, first, last) if first < last then pivot = s[last] i = first j = last - 1 while true do while i < last && s[i] < pivot do i += 1 end while j >= first && s[i] >pivot do j -= 1 end if i >= j then break end
つづきます。
30 名前:デフォルトの名無しさん [05/01/25 21:57:26 ]
temp = s[i] s[i] = s[j] s[j] = temp i += 1 j -= 1 end temp = s[i] s[i] = s[last] s[last] = temp qsort(s, first, i-1) qsort(s, i+1, last) end end
def quick_sort(s) qsort(s, 0, s.size-1) return s end