您的位置:首页 > 编程语言 > Lua

--泛型 for 的使用(lua)

2009-06-11 11:53 267 查看
--泛型 for 的使用
table_a={
{1,4,7};
{2,5,8};
{3,5,7};
{2,4,6};
{1,8};
{3,6};
{2,7};
{4,5};
};

function isSameItem(table_1,table_2)
for i,v in pairs(table_1) do
if table_2[i] ~= v then
return false;
end
end
return true;
end

a = {1,4,7};
b = {3,5,8};

function test(t)
local flag = false;
local index = 0;
for i,v in pairs(table_a) do
if(isSameItem(t,v)) then
flag = true;
index = i;
end
end
if not flag then
print("没找到");
else
print(index.."号");
end
end
test(a);
test(b);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: