complete 2083.rs 2530.rs 2721.rs 4128.rs 5584.rs 7512.rs 21519.rs 21964.rs 22862.rs 22973.rs 24123.rs 26993.rs 27514.rs 33849.rs
This commit is contained in:
39
storage/zeta/rs/completed/2083.rs
Normal file
39
storage/zeta/rs/completed/2083.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use std::io::stdin;
|
||||
|
||||
pub struct Person {
|
||||
name: String,
|
||||
age: u32,
|
||||
weight: u32,
|
||||
}
|
||||
|
||||
impl Person {
|
||||
fn is_adult(&self) -> bool {
|
||||
self.age >= 18 || self.weight >= 80
|
||||
}
|
||||
|
||||
fn is_null(&self) -> bool {
|
||||
self.age == 0 && self.weight == 0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut line = String::new();
|
||||
|
||||
loop {
|
||||
line.clear();
|
||||
stdin().read_line(&mut line).unwrap();
|
||||
let mut iter = line.trim_ascii_end().split(' ');
|
||||
let p = Person {
|
||||
name: iter.next().unwrap().to_string(),
|
||||
age: iter.next().unwrap().parse().unwrap(),
|
||||
weight: iter.next().unwrap().parse().unwrap(),
|
||||
};
|
||||
if p.is_null() {
|
||||
break;
|
||||
} else if p.is_adult() {
|
||||
println!("{} Senior", p.name);
|
||||
} else {
|
||||
println!("{} Junior", p.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user