I think you can try the following:
int max_n = 2;
int max_m = 10;
int current_position_x = 0;
int current_position_y = 8;
current_position_y += 3; // here you add a shift to your current position
if (current_position_y >= max_m)
{
current_position_x += current_position_y / max_m;
current_position_y %= max_m;
}
In this case you will go over the array as (0, 0), (0, 1) ... (0, 9), (1, 0) ... (1, 9)