How to get row and column from index?

前端 未结 4 654
南方客
南方客 2020-12-25 11:59

I\'m drawing a HUGE blank here.

Everything I\'ve found is about getting an index from a given row and column, but how do I get a row and a column from an in

4条回答
  •  死守一世寂寞
    2020-12-25 12:17

    In java, with a column offset of 1, this is a way to do it

    int offset=1;
    column = Math.floorDiv(location-offset , 3)+offset;
    row = ( (location-offset) %3 )+offset ;
    

提交回复
热议问题