class Sort
$array=[41,58,31,41,59,26]
def insertSort(count,key)
if count>=1
insertSort(count-1,$array[count-1])
i=count-1
while i>=0 and $array[i]>key
$array[i+1]=$array[i]
i=i-1
end
$array[i+1]=key
end
end
def Output
puts $array
end
end
sort=Sort.new()
sort.insertSort($array.length-1,$array[$array.length-1])
sort.Output
插入排序 递归 ruby
最新推荐文章于 2025-12-12 22:02:59 发布
5712

被折叠的 条评论
为什么被折叠?



