Triple Recursion

Problem: Given a two dimensional n by n matrix, you have to fill it by using the following rules:

Given the first value of the matrix (position (0,0)),
you have to fill all the other horizontal and vertical cells in the same row and column, by subtracting -1 from the previous value.
Then you can pass to position (1,1) by adding some value k to the value found on (0,0),
and then repeat the same operation up to the point when you reach the position (n-1, n-1).
After making all these operations, output each element of the matrix.
Input specification
You will be given 3 integers n, m, and k where 4 ≤ n ≤ 100, 5 ≤ m ≤ 100, 2 ≤ k ≤ 50. n represents the number of rows and columns in the matrix, m represents the starting value of position (0,0) and k represents the value that should be added to m while moving diagonally.

Output specification
Output each element of the matrix separated by a single space as it is shown in the sample output.

Sample Input I
5 10 7
Sample Input II
6 5 2
Sample Output I
10 9 8 7 6
9 17 16 15 14
8 16 24 23 22
7 15 23 31 30
6 14 22 30 38
Sample Output II
5 4 3 2 1 0
4 7 6 5 4 3
3 6 9 8 7 6
2 5 8 11 10 9
1 4 7 10 13 12
0 3 6 9 12 15


URL http://acm.epoka.edu.al:8080/en/problem-pid-c513?ps=1&smt=a&smpwid=0
What is the question? Is your code not working? Show us what you have so far.
CENStudent wrote:
you have to fill all the other horizontal and vertical cells in the same row and column, by subtracting -1 from the previous value.


Is a typo or does that really mean adding 1?
Topic archived. No new replies allowed.