We can access matrices using linear indexing, which follows this pattern
0 1 2
3 4 5
6 7 8
It\'s easy to get the i,j coordinates for this cas
Here's the simplest method i could think of:
int i = 1, j, x=n; while (idx > x) { i++; idx=idx-x; x--; } j=idx+(i-1); return i, j;