entrada, argumento, bucles y condición
This commit is contained in:
19
condicion/src/main.rs
Normal file
19
condicion/src/main.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
let mut entrada: String = String::new();
|
||||
|
||||
for _ in 0..3 {
|
||||
io::stdin().read_line(&mut entrada).unwrap();
|
||||
let n: i32 = entrada.trim().parse().unwrap();
|
||||
|
||||
if n < 0 {
|
||||
println!("{} es negativo", n);
|
||||
} else if n > 0 {
|
||||
println!("{} es positivo", n);
|
||||
} else {
|
||||
println!("Es cero");
|
||||
}
|
||||
entrada.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user