在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1. Arrays: 注意 #(data), # 加上 table名字 == size of 1 data = {}; 2 for y = 1 , 7 do --行 3 for x = 1 , 8 do --列 4 data[(y-1)*8+x] = (y-1)*8+x; 5 end 6 7 end 8 print(#(data)) 9 for y = 1 , 7 do 10 11 print(data[(y-1)*8+1].." "..data[(y-1)*8+2].." "..data[(y-1)*8+3].." " 12 ..data[(y-1)*8+4].." "..data[(y-1)*8+5].." "..data[(y-1)*8+6].." " 13 ..data[(y-1)*8+7].." "..data[(y-1)*8+8]); 14 15 end; 2. LinkedList: 倒序: 1 local head = nil 2 3 head = {next = head, value = "d"} 4 head = {next = head, value = "c"} 5 head = {next = head, value = "b"} 6 head = {next = head, value = "a"} 7 8 local entry = head 9 10 while entry do 11 print(entry.value) 12 13 entry = entry.next 14 end 正序: 1 head ={next = nil, value = 0} 2 per = head 3 for i = 0, 10 do 4 cur = {next = nil, value = i} 5 per.next = cur 6 per = cur 7 end 8 while head do 9 print(head.value); 10 head = head.next; 11 end
|
请发表评论