9 lines
189 B
Rust
9 lines
189 B
Rust
|
use std::ops::Div;
|
||
|
|
||
|
pub fn median<E: Div + Copy + Ord>(numbers: &[E]) -> E {
|
||
|
let mut numbers = numbers.to_vec();
|
||
|
numbers.sort();
|
||
|
let mid = numbers.len() / 2;
|
||
|
numbers[mid]
|
||
|
}
|