View Single Post
Old Dec 19th, 2006, 11:25 AM   #5
pegasus001
Hobbyist Programmer
 
pegasus001's Avatar
 
Join Date: Nov 2006
Location: 163H
Posts: 213
Rep Power: 2 pegasus001 is on a distinguished road
I think this will work :
int sum = 0;
int table[5][5] = {.....};

void solve(int i, int j, int &sum_temp)
{
     if (i =< j and i <= 5)
     {
            sum_temp += table[i][j];
            solve(i++ ,j , sum_temp);
            solve(i++, j++, sum_temp);
     }
     else if(i == 6)
     {
              if (sum < sum_temp) sum = sum_temp;
     }
}
But be careful that this program if it works correctly (i will try at home) for very large matrixes will need a lot of time solving.
pegasus001 is offline   Reply With Quote