English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

2 answers

What is that, C+?
I don't know what these two lines do:
while(i <= square.length - 1 && b >= 0)
sum = sum + square[i][b];

If you can explain that, I might be able to help.

2007-10-19 15:46:15 · answer #1 · answered by ol_skater_boy 2 · 0 0

What do you mean by a "4by4 square with all 5s"?

2007-10-19 22:48:00 · answer #2 · answered by ironduke8159 7 · 0 0

fedest.com, questions and answers