From 119e10c2a074e1604bfb293f823e754d37d51a74 Mon Sep 17 00:00:00 2001 From: Manuel Riquelme Date: Tue, 13 Jun 2023 15:15:19 +0200 Subject: [PATCH] reto00 --- ejercicios/README.md | 3 +++ ejercicios/reto00/Cargo.toml | 8 ++++++++ ejercicios/reto00/src/main.rs | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 ejercicios/README.md create mode 100644 ejercicios/reto00/Cargo.toml create mode 100644 ejercicios/reto00/src/main.rs diff --git a/ejercicios/README.md b/ejercicios/README.md new file mode 100644 index 0000000..6d434c6 --- /dev/null +++ b/ejercicios/README.md @@ -0,0 +1,3 @@ +# Ejercicios de: + +### https://github.com/mouredev/retos-programacion-2023 diff --git a/ejercicios/reto00/Cargo.toml b/ejercicios/reto00/Cargo.toml new file mode 100644 index 0000000..29ce4fe --- /dev/null +++ b/ejercicios/reto00/Cargo.toml @@ -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] diff --git a/ejercicios/reto00/src/main.rs b/ejercicios/reto00/src/main.rs new file mode 100644 index 0000000..ecdf6ab --- /dev/null +++ b/ejercicios/reto00/src/main.rs @@ -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) + } +}