commit 19f8a858753751ff497bb2a3baec5f6189962d5c Author: bot50 Date: Tue Feb 20 21:27:41 2024 +0000 kukemuna-cs50/problems/2024/x/mario/more@20240220T212741.689705436Z 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"); + } +}