code-examples/current/algorithms/rust_algo/src/main.rs

20 lines
366 B
Rust
Raw Normal View History

2025-03-01 10:41:14 +00:00
fn main() {
let mut v = [4.1, -5.1, 1.1, -3.1, 2.1];
v.sort_by(f64::total_cmp);
println!("Hello, world!");
for el in v {
println!("Element {}.", el);
}
let mut v = vec![5, 2, 1];
v.push(2);
v.push(5);
for (idx, elem) in v.iter().enumerate() {
println!("Val: {}. {}.", idx, elem);
}
println!("Done");
}