Skip to content

Commit 5fdbdfd

Browse files
committed
Add Min Max Recursivo em RUST
1 parent 982014a commit 5fdbdfd

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
2424
| [Fibonacci][17] | [C/C++](./src/c/Fibonacci.cpp) | [Java](./src/java/Fibonacci.java) | [Python](./src/python/fibonacci.py) | [Go](./src/go/fibonacci/fibonacci.go) | [Ruby](./src/ruby/Fibonacci.rb) | [JS](./src/javascript/Fibonacci.js) | Pascal | [Swift](./src/swift/fibonacci.swift) | [Rust](./src/rust/fibonacci.rs) |
2525
| [Máximo Recursivo][26] | [C/C++](./src/c/MaxRecursivo.c) | Java | Python | Go | Ruby | [JS](./src/javascript/MaxRecursive.js) | Pascal | Swift | Rust |
2626
| [Mín. e Máx. Iterativo][27] | C/C++ | [Java](./src/java/MaxMinArray.java) | [Python](./src/python/min_max_iterativo.py) | Go | Ruby | [JS](./src/javascript/IterativeMinAndMax.js) | Pascal | Swift | [Rust](./src/rust/min_max_iterativo.rs) |
27-
| [Mín. e Máx. Recursivo][28] | [C/C++](./src/c/MaxMinRecursivo.c) | Java | [Python](./src/python/maximo_minimo_recursivo.py) | [Go](./src/go/maximominimo/MaximoMinimo.go) | Ruby | [JS](./src/javascript/RecursiveMinAndMax.js) | Pascal | Swift | Rust |
27+
| [Mín. e Máx. Recursivo][28] | [C/C++](./src/c/MaxMinRecursivo.c) | Java | [Python](./src/python/maximo_minimo_recursivo.py) | [Go](./src/go/maximominimo/MaximoMinimo.go) | Ruby | [JS](./src/javascript/RecursiveMinAndMax.js) | Pascal | Swift | [Rust](./src/rust/min_max_recursivo.rs) |
2828
| Mín. e Máx. D&C | C/C++ | Java | [Python](./src/python/maximo_recursivo_dc.py) | [Go](./src/go/maximominimo/MaximoMinimo.go) | Ruby | JS | Pascal | Swift | Rust |
2929
| [Passeio do Cavalo][30] | C/C++ | Java | [Python](./src/python/passeio_do_cavalo.py) | Go | Ruby | JS | Pascal | Swift | Rust |
3030
| [Torre de Hanói][33] | C/C++ | [Java](./src/java/TorreDeHanoi.java) | [Python](./src/python/torre_de_hanoi.py) | [Go](./src/go/hanoi/hanoi.go) | [Ruby](./src/ruby/Hanoi.rb) | [JS](./src/javascript/TorreDeHanoi.js) | Pascal | Swift | [Rust](./src/rust/torre_hanoi.rs) |

src/rust/min_max_recursivo.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
fn main() {
2+
let vetor = vec![54,42,11,33,24,99,77,80];
3+
min_max(vetor, i32::MAX, i32::MIN, 0);
4+
}
5+
6+
fn min_max(vetor: Vec<i32>, mut min: i32, mut max: i32, indice: usize) {
7+
if vetor[indice] < min {
8+
min = vetor[indice];
9+
}
10+
if vetor[indice] > max {
11+
max = vetor[indice];
12+
}
13+
if indice < vetor.len() - 1 {
14+
min_max(vetor, min, max, indice + 1);
15+
} else {
16+
println!{"Data: {:?}", vetor};
17+
println!{"Min.: {:?}", min};
18+
println!{"Max.: {:?}", max};
19+
}
20+
}

0 commit comments

Comments
 (0)