You are viewing a single comment's thread. Return to all comments →
Rust:
fn plusMinus(arr: &[i32]) { let mut pos: f32 = 0.0; let mut neg: f32 = 0.0; let mut zer: f32 = 0.0; let all = arr.len() as f32; for &i in arr { match i { i if i > 0 => pos += 1 as f32, i if i < 0 => neg += 1 as f32, i => zer += 1 as f32, } } println!("{}", pos / all); println!("{}", neg / all); println!("{}", zer / all); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
Rust: