![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
排序算法
shrimp0755
这个作者很懒,什么都没留下…
展开
-
Lua——冒泡算法排序
开始学习lua了,记录一下 local var = {1,4,7,2,5,8,3,6,9} local index = #var for i = 1,index - 1 do for j = 1,index - i do if var[j] > var[j+1] then local temp = var[j+1] var[j+1] = var[j] var[j] = temp end ...原创 2020-10-24 14:45:09 · 325 阅读 · 0 评论 -
Lua——选择算法排序
function select_Sort(array) for i = 1,#array - 1 do local index = i for j = i + 1,#array do if array[j] < array[index] then index = j end end if index ~=i then array[i],array[index]...原创 2020-10-24 14:56:30 · 132 阅读 · 0 评论 -
Lua——插入算法排序
local function insert_sort(array) for i = 2,#array do local temp = array[i] local index = i- 1--记录插入的数前一个位置的索引 while index >= 1 and array[index] >= temp do array[index+1] = array[index]--//前面的数往后移动一位 ...原创 2020-10-25 10:47:16 · 205 阅读 · 0 评论