Skip to content

Commit a9c216f

Browse files
committed
[rust] Adiciona Algoritmos de Ordenação bubble_sort
1 parent 2b04411 commit a9c216f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
4949
| Algoritmos de Ordenação | C/C++ | Java | Python | Go | Ruby | JS | Pascal | Swift | Rust |
5050
|-------------------------------------|-------|------|--------|----|------|----|--------|-------|------|
5151
| [Bogo Sort][34] | C/C++ | [Java](./src/java/BogoSort.java) | Python | Go | Ruby | JS | Pascal | Swift | Rust |
52-
| [Bubble Sort][35] | [C/C++](./src/c/BubbleSort.cpp) | [Java](./src/java/BubbleSort.java) | [Python](./src/python/bubble_sort.py) | [Go](./src/go/bubbleSort/bubbleSort.go) | [Ruby](./src/ruby/bubble_sort.rb) | [JS](./src/javascript/BurbbleSort.js) | [Pascal](./src/pascal/bubble-sort.pas) | Swift | Rust |
52+
| [Bubble Sort][35] | [C/C++](./src/c/BubbleSort.cpp) | [Java](./src/java/BubbleSort.java) | [Python](./src/python/bubble_sort.py) | [Go](./src/go/bubbleSort/bubbleSort.go) | [Ruby](./src/ruby/bubble_sort.rb) | [JS](./src/javascript/BurbbleSort.js) | [Pascal](./src/pascal/bubble-sort.pas) | Swift | [Rust](./src/rust/bubble_sort.rs) |
5353
| [Bucket Sort][36] | C/C++ | [Java](./src/java/BucketSort.java) | Python | Go | [Ruby](./src/ruby/bucket_sort.rb) | JS | Pascal | Swift | Rust |
5454
| [Cocktail Sort][37] | C/C++ | Java | Python | [Go](./src/go/cocktailsort/cocktailsort.go) | Ruby | JS | Pascal | Swift | Rust |
5555
| [Comb Sort][38] | C/C++ | Java | Python | [Go](./src/go/combsort/combsort.go) | Ruby | [JS](./src/javascript/CombSort.js) | Pascal | Swift | Rust |

src/rust/bubble_sort.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn bubble_sort(mut slice: Vec<i32>) -> Vec<i32> {
2+
for i in 0..slice.len() {
3+
for j in 0..slice.len() - 1 - i {
4+
if slice[j] > slice[j + 1] {
5+
slice.swap(j, j + 1);
6+
}
7+
}
8+
}
9+
slice
10+
}
11+
fn main(){
12+
println!("{:?}", bubble_sort(vec![4, 65, 2, -31, 0, 99, 2, 83, 782, 1]));
13+
}

0 commit comments

Comments
 (0)