This commit is contained in:
DavidOnTop 2024-12-10 08:02:45 +01:00
parent f1b2a8c9ba
commit c0226433a0
No known key found for this signature in database
GPG key ID: 5D05538A45D5149F

View file

@ -1 +1,14 @@
pub fn main() {}
pub fn main() {
let mut v = Vec::with_capacity(20);
for _ in 0..20 {
v.push(rand::random::<f32>() * 40.0 - 20.0);
}
v.sort_by(|a, b| a.partial_cmp(b).unwrap());
println!("{:?}", v);
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let input: f32 = input.trim().parse().unwrap();
println!("{}", v.iter().position(|x| *x == input).unwrap_or(usize::MAX))
}