Problème return et initialisation
Bonjour,
voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public double surfaceCoque(double[][] tabCentre) {
double S = 0;
double S1 = 0;
double S2 = 0;
int n = tabCentre[0].length;
if (n / 2 == (n + 1) / 2) {
for (int i = 0; i < n / 2 - 1; i++)
S += (tabCentre[i][0] - tabCentre[n - 1 - i][0])
* (tabCentre[i][1] - tabCentre[i + 1][1]);
return S;
} else {
for (int i = 0; i < n; i++) {
S1 += (tabCentre[0][i] - tabCentre[0][n - 1 - i])
* (tabCentre[1][i] - tabCentre[1][i + 1]);
S2 = ((tabCentre[0][n / 2 - 1] - tabCentre[0][n / 2 + 1]) * (tabCentre[1][n / 2 - 1] - tabCentre[1][n / 2])) / 2;
S = S1 + S2;
}
return S;
}
} |
mon pb est que quelque soit la valeur que j'initialise ici 0, c'est celle là qu'il me retourne :?
Pourquoi ?
Merci