So ive got this recursive function:
int solution(int i, int j, int n, int m, int **A, int c, int **B, int **C, int *D, int *E) {
    int a, b, k, w;
    if (i < n && j < m) {
        B[i + j][0] = i;
        B[i + j][1] = j;
        D[i + j] = c;
    }
    else if (i == n && j == m) {
        B[i + j - 1][0] = i;
        B[i + j - 1][1] = j;
        D[i + j - 1] = c;
    }
    if (A[i][j] == 'C') {
        c++;
    }
    if (i == n - 1 && j == m - 1) {
        if (c > maxcoins) {
            for (w = 0; w < n + m; w++) {
                C[w][0] = B[w][0];
                C[w][1] = B[w][1];
                E[w] = D[w];
            }
            maxcoins = c;
        }
    }
    if (i < n - 1) {
        a = i + 1;
        k = solution(a, j, n, m, A, c, B, C, D, E);
    }
    if (j < m - 1) {
        b = j + 1;
        k = solution(i, b, n, m, A, c, B, C, D, E);
    }
}
and i want to convert it to a dynamic programming solution but i cant figure out how to do it. Basically given a 2D array of C and . ,C representing coins and . blank spots it has to figure out the maximum number of coins one can collect only by moving down and right(maxcoins is an external variable). I would appreciate it if you got any answears that might help, thanks!
 
    