Let's follow the code:
count = 1
mtrx[0][0] = 1
print Linha:0 Col:0 INT:1
------new loop-----------
count = 2
mtrx[0][1] = 2
print Linha:0 Col:1 INT:2
------new loop-----------
etc.
First from i=0 -> 19
Then from j=0 -> 9
This is equivalent to:
0,0
0,1
0,2
(...)
0,9
1,0
(...)
19,9 <- Latest Matrix Address.
It's just like a spreadsheet:
0 1 2
0 [0,0] [0,1] [0,2]
1 [1,0] [1,1] [1,2]
2 [2,0] [2,1] [2,2]
3 [3,0] [3,1] [3,2]
4 [4,0] [4,1] [4,2]
#include <stdio.h>
int main ()
{
int mtrx [20][10];
int i,j,count;
count=1;
for (i=0;i<20;i++)
for (j=0;j<10;j++)
{
mtrx[i][j]=count;
count++;
printf("\nLinha:%d Col:%d INT:%d",i,j,mtrx[i][j]);
}
getchar(); //No exemplo acima, a matriz mtrx é preenchida, sequencialmente por linhas, com os números de 1 a 200.
}