2. Initialize the matrix (clear its content). In this case not realy important.
1 2 3
for (int x=0;x<5;x++)
for (int y=0;y<5;y++)
matrix[x][y] = 0;
3. Now the engine or heard of your code. Write a function which gives you the next number of the row!
1 2 3 4 5 6 7
int fn(int value) {
value ++;
if (value > 5)
value = 1;
return value;
}
4. Now you can fill your matrix
1 2 3 4 5 6 7
for (int x=0;x<5;x++) {
int value = x+1; // starting first number of the row with 1 until 5
for (int y=0;y<5;y++) {
value = fn(value);
matrix[x][y] = value;
}
}