public int sumOtherDiag()
{
int b = square.length - 1;
int i = 0;
int sum = 0;
while(i <= square.length - 1 && b >= 0)
{
sum = sum + square[i][b];
i++;
b--;
}
return sum;
}
does not sum correctly for 4by4 square with all 5s it gives me 15.
The other diagonale is:
*
*
*
*
2007-10-19
15:36:26
·
2 answers
·
asked by
Jake L
3
in
Science & Mathematics
➔ Mathematics
this is java, umm, sum = *(*** is taking the sum of the diagno5
5 by 5 is 5 rows 5 columns
2007-10-20
13:27:19 ·
update #1