- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray.lua
More file actions
Latest commit
48 lines (43 loc) · 642 Bytes
/
Copy pathArray.lua
File metadata and controls
48 lines (43 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---array的遍历
--[[
array={"asdf","fsdaf","sadf"}
for i=1,3 do
print(array[i])
end
array={}
for i=-5,-1 do
array[i]=-i
end
for i=-5,-3 do
print(array[i])
end
--]]
---多维数组的遍历
--[[
array={{"xm","xh"},{"xl","xa"},{"zs","ls"},{"wmz","nm"}}
--print(array[1][2])
for i=1,4 do
for j=1,2 do
print(array[i][j])
end
end
--]]
---多维数组的两种声明赋值方法
array={{},{},{}} --
fori=1,3do
forj=1,3do
array[i][j]=i+j;
end
end
array={}
fori=1,3do
array[i]={}
forj=1,3do
array[i][j]=i+j;
end
end
fori=1,3do
forj=1,3do
print(array[i][j].."元素")
end
end