Some basic rust algorithms.
parent
2edf415e2a
commit
4463b79496
|
@ -0,0 +1 @@
|
|||
target
|
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "rust_algo"
|
||||
version = "0.1.0"
|
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "rust_algo"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
|
@ -0,0 +1,19 @@
|
|||
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");
|
||||
}
|
Loading…
Reference in New Issue