From 586ac8d956b097cf45c473c79d187c19a4e32a5d Mon Sep 17 00:00:00 2001 From: kukemuna Date: Tue, 20 Feb 2024 23:26:39 +0200 Subject: [PATCH] automated commit by check50 [check50=True] --- mario.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 mario.c diff --git a/mario.c b/mario.c new file mode 100644 index 0000000..28d3999 --- /dev/null +++ b/mario.c @@ -0,0 +1,52 @@ +#include +#include + +void build_ramp(int height); + +int main(void) +{ + int height; + // Only accept positive integer + do + { + height = get_int("Height: "); + } + while (height < 1); + + build_ramp(height); + return 0; +} + + +void build_ramp(int height) +{ + int space, row, block; + + // Print row(s) + for (row = 0; row < height; row++) + { + // Print spaces + for (space = 0; space < height - row - 1; space++) + { + printf(" "); + } + + // Print first set of blocks + for (block = 0; block <= row; block++) + { + printf("#"); + } + + // Print gap + printf(" "); + + // Print other set of blocks + for (block = 0; block <= row; block++) + { + printf("#"); + } + + // Print newline + printf("\n"); + } +}