Finished max()

This commit is contained in:
artem.didytschuk 2020-08-31 22:27:42 +02:00
parent 2f9676749f
commit 027abe4550
1 changed files with 11 additions and 1 deletions

View File

@ -123,7 +123,17 @@ public class Arrays {
* Für ein leeres Array wird 0 zurück gegeben.
*/
public int max( int[] pArray ) {
return 0;
if( pArray.length == 0 ) {
return 0;
}
int max = pArray[0];
for( int i = 1; i < pArray.length; i++ ) {
if( pArray[i] > max ) {
max = pArray[i];
}
}
return max;
}
/**