sum() finished

This commit is contained in:
artem.didytschuk
2020-08-31 22:29:57 +02:00
parent 027abe4550
commit b8abf25cf2

View File

@@ -143,8 +143,15 @@ public class Arrays {
* Für ein leeres Array wird 0 zurück gegeben.
*/
public int sum( int[] pArray ) {
if( pArray.length == 0 ) {
return 0;
}
int sum = 0;
for( int i = 0; i < pArray.length; i++ ) {
sum += pArray[i];
}
return sum;
}
/**
* Berechnet den Mittelwert (average) eines