algorithm - How do I get the row and column of a table with indices. -
i have table has x columns indexes ordered horizontally:
 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14   and table x rows indexes ordered vertically:
 0  5 10 15  1  6 11 16  2  7 12  3  8 13  4  9 14   with formulas row , column number of index in these 2 cases?
for first table, row = num / x , col = num % x.
for second table, indices swapped: row = num % x , col = num / x.
here, / stands integer division (rounded down) , % taking remainder of division.
Comments
Post a Comment