-- JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
print "Hello world!"
print("========")
math.randomseed(os.time())
array_X=math.random(2,4)
print("列数:"..array_X)
array_Y=math.random(2,4)
print("行数:"..array_Y)
list={}
for i=0,array_Y do
newMeta={}
for j=0,array_X do
randomNumber=math.random(0,15)
print("Output:"..randomNumber)
newMeta[j]=randomNumber
end
list[i]=newMeta
print("换行")
end
SBlocation={}
for i=0,array_X do
newMeta={}
count=0
for j=0,array_Y do
if(list[i][j]>=13) then
newMeta[count]=j
count=count+1
end
end
SBlocation[i]=newMeta
end
print("结果")
for i=0,array_Y do
for j=0,#SBlocation[i] do
print("Output:"..SBlocation[i][j])
end
print("换行")
end
--标准答案
-- math.randomseed(os.time())
-- --生成随机的二维数组
-- local item_list = {}
-- for i = 1, 5 do
-- item_list[i] = {}
-- for j = 1, 3 do
-- item_list[i][j] = math.random(0, 15)
-- end
-- end
--当出现 13,14,15时,将其坐标记录在表SBlocation中
-- local SBlocation = {}
-- for i = 1, 5 do
-- SBlocation[i]={}
-- for j = 1 , 3 do
-- if 13 == item_list[i][j] or 14 == item_list[i][j] or 15 == item_list[i][j] then
-- table.insert(SBlocation[i],j)
-- end
-- end
-- end
-- --输出item_list&SBlocation
-- for i = 1, #item_list do
-- print(table.concat( item_list[i], ", "))
-- end
-- for i = 1, #SBlocation do
-- print(table.concat( SBlocation[i], ", "))
-- end