/
NikolayIvkin
/
TheAlgorithms
Обзор
Документация
Войти
/
NikolayIvkin
/
TheAlgorithms
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/com/thealgorithms/maths/FindMax.java
27 строк
713 B
Abhinav Pandey
Improved code readability and code quality (#4663)
11 окт 2023, 14:59
Не верифицирован
11 окт 2023, 14:59
152e290
Код
Авторство
О чём код?
package com.thealgorithms.maths; public final class FindMax { private FindMax() { } /** * @brief finds the maximum value stored in the input array * * @param array the input array * @exception IllegalArgumentException input array is empty * @return the maximum value stored in the input array */ public static int findMax(final int[] array) { int n = array.length; if (n == 0) { throw new IllegalArgumentException("Array must be non-empty."); } int max = array[0]; for (int i = 1; i < n; i++) { if (array[i] > max) { max = array[i]; } } return max; } }