Skip to content

Commit 8256728

Browse files
author
若时间无垠_笔记本
committed
增加Lua
1 parent 53ebf45 commit 8256728

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lua/常用函数方法.lua

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---[ Table 最大值以及返回的索引 ]
2+
function Table_maxn(t)
3+
local mn=nil;
4+
for k, v in pairs(t) do
5+
if(mn==nil)
6+
then
7+
mn=v
8+
end
9+
if mn < v
10+
then
11+
mn = v
12+
end
13+
end
14+
return mn
15+
end
16+
tbl = {[1] = 2, [2] = 6, [3] = 34, [26] =5}
17+
print("tbl 最大值:", table_maxn(tbl))
18+
print("tbl 长度 ", #tbl)

0 commit comments

Comments
 (0)