mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-09 03:59:38 +08:00
fix: update FindMin and fix #1170
This commit is contained in:
@ -5,7 +5,7 @@ public class FindMin {
|
|||||||
//Driver
|
//Driver
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int[] array = {2, 4, 9, 7, 19, 94, 5};
|
int[] array = {2, 4, 9, 7, 19, 94, 5};
|
||||||
System.out.println("min = " + findMax(array));
|
System.out.println("min = " + findMin(array));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,7 +14,7 @@ public class FindMin {
|
|||||||
* @param array the array contains element
|
* @param array the array contains element
|
||||||
* @return min value
|
* @return min value
|
||||||
*/
|
*/
|
||||||
public static int findMax(int[] array) {
|
public static int findMin(int[] array) {
|
||||||
int min = array[0];
|
int min = array[0];
|
||||||
for (int i = 1; i < array.length; ++i) {
|
for (int i = 1; i < array.length; ++i) {
|
||||||
if (array[i] < min) {
|
if (array[i] < min) {
|
||||||
|
Reference in New Issue
Block a user