September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -0,0 +1,30 @@
use std::io::{self, BufRead};
fn op(x: f32) -> Option<f32> {
let y = x.abs().sqrt() + 5.0 * x * x * x;
if y < 400.0 {
Some(y)
} else {
None
}
}
fn main() {
println!("Please enter 11 numbers (one number per line)");
let stdin = io::stdin();
let xs = stdin
.lock()
.lines()
.map(|ox| ox.unwrap().trim().to_string())
.flat_map(|s| str::parse::<f32>(&s))
.take(11)
.collect::<Vec<_>>();
for x in xs.into_iter().rev() {
match op(x) {
Some(y) => println!("{}", y),
None => println!("overflow"),
};
}
}