Skip to content

Commit 41bf038

Browse files
authored
Merge pull request kelvins#150 from AJohnsoon/main
Mín e Máx Recursivo
2 parents 15690ae + 7419c77 commit 41bf038

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,8 +1026,8 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
10261026
</a>
10271027
</td>
10281028
<td> <!-- Java -->
1029-
<a href="./CONTRIBUTING.md">
1030-
<img align="center" height="25" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" />
1029+
<a href="./src/java/MinMaxRecursivo.java">
1030+
<img align="center" height="25" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/java/java-original.svg" />
10311031
</a>
10321032
</td>
10331033
<td> <!-- Python -->

src/java/MinMaxRecursivo.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class MinMaxRecursivo {
2+
3+
public static void main(String[] args){
4+
int[] arr = {9,8,13,33,18,20,88,14,40,77};
5+
MinMax(arr, arr[0],arr[0],0);
6+
}
7+
8+
public static void MinMax(int vect[], int minimo, int maximo, int indice){
9+
if(vect[indice] < minimo ){
10+
minimo = vect[indice];
11+
}
12+
if(vect[indice] > maximo){
13+
maximo = vect[indice];
14+
}
15+
if(indice < vect.length-1 ){
16+
MinMax(vect, minimo,maximo, indice+1);
17+
}
18+
else {
19+
System.out.println("Mínimo :" + minimo + "\nMáximo: "+maximo);
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)