indexing - Trouble with a equation in Java -
i'm working on 15 puzzle game android school. sadly i've ran problem.
i need rewrite equation row , column instead of index. have @ code , se if guys can me out!
this takes row , column , return me corresponding index.
int index = 4 * (row - 1) + (column - 1);
however, turn index row , column. know how sort of reverse equation return row , column 2 different ints.
thank, mikael
try this:
row = index / 4 + 1; column = (index % 4) + 1;
note (and original formula) works if column < 5
(which is, of course, 15 puzzle).
Comments
Post a Comment