lua 数组问题。
数组1={"1","2","3","4","5","6","7","8"}数组2={"3","6","7","8"}fornum=1,数组1dox=numfordo打印2...
数组1 = {"1","2","3","4","5","6","7","8"}
数组2 = {"3","6","7","8"}
for num = 1, 数组1 do
x = num
for do
打印2数组相同的值
end
end
如何打印两数组相同的值 展开
数组2 = {"3","6","7","8"}
for num = 1, 数组1 do
x = num
for do
打印2数组相同的值
end
end
如何打印两数组相同的值 展开
1个回答
展开全部
for i=1,#数组1 do
x=数组1[i]
for k,v in 数组2 do
if v == x then
print(v)
end
end
end
x=数组1[i]
for k,v in 数组2 do
if v == x then
print(v)
end
end
end
更多追问追答
追问
不同的呢?for k,v in 数组2 do
这个应该是for k,v in ipairs(数组2) do
追答
for k,v in pairs(数组2)
不能有i,你的数组2不是一个真正的数组
,我直接在网页上敲的,敲漏了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询