local t = { 333,342,3,22,39,55,67,80,999}
local a=0
for i=1 , #t ,1 do
for x=1 , #t ,1 do
if t[i]>t[x] then
a =t[i]
t[i]=t[x]
t[x]=a
end
end
end
============================
for i=1 ,#t ,1do
print(t[i])
end
这个代码重点是替换.
a =t[i]
t[i]=t[x]
t[x]=a
t[1]的值小于t[2]就把1和2的值互换.然后坐标1和坐标3比较.如果3大就再互换.
微信号hpot1984...求红包