From ccc50fbb7f14c63f137cba6d46c7a26bd644cb11 Mon Sep 17 00:00:00 2001 From: Araozu Date: Tue, 20 Aug 2024 16:40:08 -0500 Subject: [PATCH] es blog: add quizes to zig 6 --- src/components/Blog/Exercise.astro | 42 +++++++ src/components/Blog/Sh.astro | 5 + src/pages/blog/es/index.astro | 2 +- ...programacion-06.md => programacion-06.mdx} | 103 +++++++++++++++++- 4 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 src/components/Blog/Exercise.astro create mode 100644 src/components/Blog/Sh.astro rename src/pages/blog/es/{programacion-06.md => programacion-06.mdx} (62%) diff --git a/src/components/Blog/Exercise.astro b/src/components/Blog/Exercise.astro new file mode 100644 index 0000000..efe78cf --- /dev/null +++ b/src/components/Blog/Exercise.astro @@ -0,0 +1,42 @@ +
+ + +
+ +
+ + +
+ + \ No newline at end of file diff --git a/src/components/Blog/Sh.astro b/src/components/Blog/Sh.astro new file mode 100644 index 0000000..57e1a4e --- /dev/null +++ b/src/components/Blog/Sh.astro @@ -0,0 +1,5 @@ +--- +const {code} = Astro.props; +--- + +
{code}
\ No newline at end of file diff --git a/src/pages/blog/es/index.astro b/src/pages/blog/es/index.astro index 07da64a..175acc3 100644 --- a/src/pages/blog/es/index.astro +++ b/src/pages/blog/es/index.astro @@ -1,7 +1,7 @@ --- import BlogLayout from "../../../layouts/BlogLayout.astro"; -const allPosts = await Astro.glob("./*.md"); +const allPosts = await Astro.glob("./*.{md,mdx}"); --- diff --git a/src/pages/blog/es/programacion-06.md b/src/pages/blog/es/programacion-06.mdx similarity index 62% rename from src/pages/blog/es/programacion-06.md rename to src/pages/blog/es/programacion-06.mdx index af736a1..56e2b36 100644 --- a/src/pages/blog/es/programacion-06.md +++ b/src/pages/blog/es/programacion-06.mdx @@ -10,6 +10,9 @@ image: alt: "" caption: "" --- +import Exercise from "../../../components/Blog/Exercise.astro" +import Sh from "../../../components/Blog/Sh.astro" + En el artículo anterior escribimos nuestro primer programa: Hola mundo. En este artículos vamos a modificar el mensaje @@ -148,7 +151,6 @@ pub fn main() !void { Cada instrucción se coloca en una linea nueva. - ## Siguiente En el siguiente artículo continuaremos trabajando @@ -156,5 +158,104 @@ con impresiones, y aprenderemos qué es ese dato adicional misterioso. +## Ejercicios + +Resuelve estos ejercicios en tu editor de texto VSCode. +Al ejecutar debe salir en el terminal el mismo resultado +que el del enunciado. + +Si estas atascado en un problema puedes mostrar la solución, +pero intenta resolverlos por ti mismo antes. + + + 1: Utiliza `std.debug.print` para imprimir: + + + + + ```zig + const std = @import("std"); + + pub fn main() !void { + std.debug.print("Son las 10:00pm", .{}); // [!code focus] + } + ``` + + + + + 2: Escribe un programa que imprima el siguiente texto + (necesitaras usar `\n` para crear 2 lineas): + + + + + ```zig + const std = @import("std"); + + pub fn main() !void { + std.debug.print("hola\nmundo", .{}); // [!code focus] + } + ``` + + + + + 3: Escribe un programa que imprima el siguiente texto. + Utiliza 1 `std.debug.print` para cada linea + + + + + ```zig + const std = @import("std"); + + pub fn main() !void { + std.debug.print("El\n", .{}); // [!code focus:4] + std.debug.print("cielo\n", .{}); + std.debug.print("es\n", .{}); + std.debug.print("azul\n", .{}); + } + ``` + + + + + 4: Escribe un programa que imprima el siguiente texto. + Utiliza **solo 1** `std.debug.print`; + + + + + ```zig + const std = @import("std"); + + pub fn main() !void { + std.debug.print("El\ncielo\nes\nazul\n", .{}); // [!code focus] + } + ``` + + + + + 5: Escribe un programa que imprima el siguiente texto + (fíjate en los espacios en blanco antes de cada palabra): + + + + + ```zig + const std = @import("std"); + + pub fn main() !void { + std.debug.print(" El\n", .{}); // [!code focus:4] + std.debug.print(" cielo\n", .{}); + std.debug.print(" es\n", .{}); + std.debug.print(" azul\n", .{}); + } + ``` + + +