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 )
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论