You are viewing a single comment's thread. Return to all comments →
fn plusMinus(arr: &[i32]) { let mut a = 0; let mut b = 0; let mut c = 0; for i in 0..arr.len(){ if arr[i] == 0 { a += 1 } if arr[i] > 0{ b += 1 } if arr[i] < 0{ c += 1 } }; let len_float = arr.len() as f64; let calc_a = a as f64 / len_float; let calc_b = b as f64 / len_float; let calc_c = c as f64 / len_float; println!("{:.6}", calc_b); println!("{:.6}", calc_c); println!("{:.6}", calc_a); }
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