reto00
This commit is contained in:
3
ejercicios/README.md
Normal file
3
ejercicios/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Ejercicios de:
|
||||
|
||||
### https://github.com/mouredev/retos-programacion-2023
|
||||
8
ejercicios/reto00/Cargo.toml
Normal file
8
ejercicios/reto00/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "reto00"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
22
ejercicios/reto00/src/main.rs
Normal file
22
ejercicios/reto00/src/main.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Escribe un programa que muestre por consola (con un print) los
|
||||
* números de 1 a 100 (ambos incluidos y con un salto de línea entre
|
||||
* cada impresión), sustituyendo los siguientes:
|
||||
* - Múltiplos de 3 por la palabra "fizz".
|
||||
* - Múltiplos de 5 por la palabra "buzz".
|
||||
* - Múltiplos de 3 y de 5 a la vez por la palabra "fizzbuzz".
|
||||
*/
|
||||
|
||||
fn main() {
|
||||
for num in 1..101 {
|
||||
let mut texto = num.to_string();
|
||||
if num % 3 == 0 && num % 5 == 0 {
|
||||
texto = String::from("fizzbuzz")
|
||||
} else if num % 3 == 0 {
|
||||
texto = String::from("fizz")
|
||||
} else if num % 5 == 0 {
|
||||
texto = String::from("buzz")
|
||||
}
|
||||
println!("{}", texto)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user