Skip to content

Instantly share code, notes, and snippets.

@ursulams
Last active March 11, 2024 13:11
Show Gist options
  • Save ursulams/2b6a73499b29104bf7be10cdf16f3b5a to your computer and use it in GitHub Desktop.
Save ursulams/2b6a73499b29104bf7be10cdf16f3b5a to your computer and use it in GitHub Desktop.
cs50 mario.c
# include <cs50.h>
# include <stdio.h>
void print_row(int spaces, int bricks);
int main(void)
{
int n;
do
{
n = get_int("Height?: ");
}
while(n < 1 || n > 8); //handle if not acceptable input value
for(int i = 0; i < n; i++)
{
print_row(n - 1 - i, i + 1);
}
}
void print_row(int spaces, int bricks)
{
for (int i = 0; i < spaces; i++)
{
printf(" ");
}
for (int i = 0; i < bricks; i++)
{
printf("#");
}
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment