--一维数组,数组的成员是字符串
array = {"Lua","Study"};
for i = 1 , 2 do
print(array[i]);
end
--一维数组,数组的成员是整型数据
array1 = {1,2,3,4,5,6,7,8,9,10};
for i = 1 , 10 do
print(i);
end
--循环执行次数
--第一次 i = 1 , j = 1 , array[i][j] = i * j = 1 * 1 = 1
--第二次 i = 1 , j = 2 , array[i][j] = i * j = 1 * 2 = 2
--第三次 i = 2 , j = 1 , array[i][j] = i * j = 2 * 1 = 2
--第四次 i = 2 , j = 2 , array[i][j] = i * j = 2 * 2 = 4
--初始化一个2 * 2 的多维数组
array = {};
for i = 1 , 2 do
array[i] = {} ;
for j = 1 , 2 do
array[i][j] = i * j ;
end
end
--打印这个数组的值
for i = 1 , 2 do
for j = 1 , 2 do
print(array[i][j]);
end
end