entrada, argumento, bucles y condición

This commit is contained in:
2023-06-02 18:44:19 +02:00
parent c945ae68ec
commit bf9b2271d0
9 changed files with 105 additions and 1 deletions

8
condicion/Cargo.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "condicion"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

19
condicion/src/main.rs Normal file
View 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();
}
}