reset password
Author Message
ZombieD
Posts: 14
Posted 23:44 Mar 07, 2013 |

So, I think I've been able to figure out most of the steps and loops to calculate everything I need. The only issue I've had is the Minor Diagonal. My total keeps coming to zero. I'm not sure why.

int total = 0;
        
        for (int row = 0 , column = table[0].length ; row > table[0].length  ; row++ , column--){
            total += table[row][column];
        }
        return total;

The row starts at 0 and the column starts at the column length so it is the right hand corner and I increase the row to keep moving further down the list and I decrease column to move over to the left . I can't see what I'm doing wrong. Any ideas?

Thanks,

JD

 

csns_kaka
Posts: 3
Posted 08:18 Mar 08, 2013 |

The reason that  the result came out "0", it is because you return it to "total" and which initialized to zero.

Try either use void for the method, or return to the column = table[0].length.  (but I am not really sure, please try) ( I have not started my homework yet. ><) ^^

 

kknaur
Posts: 540
Posted 20:53 Mar 08, 2013 |

Check your loop continuation condition to make sure that it is formatted properly.  I think the way you have it makes the condition false every time so the loop never executes.