Created
August 2, 2017 14:54
-
-
Save segfo/923bdd4f9b719d8667e914fac9e27e32 to your computer and use it in GitHub Desktop.
最小値、最大値を取得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! max { | |
($x:expr) => ( $x ); | |
($x:expr, $($xs:expr),+) => { | |
{ | |
use std::cmp::max; | |
max($x, max!( $($xs),+ )) | |
} | |
}; | |
} | |
macro_rules! min { | |
($x:expr) => ( $x ); | |
($x:expr, $($xs:expr),+) => { | |
{ | |
use std::cmp::min; | |
min($x, min!( $($xs),+ )) | |
} | |
}; | |
} | |
fn main(){ | |
let min=min!(3,2,10,0); | |
let max=max!(3,2,10,0); | |
println!("min:{}\nmax:{}",min,max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment