• + 0 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);
    }