How do you get row back out of n?
local n = row * cols + col
local c开发者_如何转开发 = n % cols
local r = ?
Using some simple arithmetic...
You have
n = rows * cols + col
subtract col from both sides
n - col = rows * cols
divide by cols on both sides
(n - col) / cols = rows
Assuming col < cols holds, you could do it with integer division as rows = n / cols.
local r = int( n / cols )
加载中,请稍侯......
精彩评论