Last active
March 11, 2024 13:11
-
-
Save ursulams/2b6a73499b29104bf7be10cdf16f3b5a to your computer and use it in GitHub Desktop.
cs50 mario.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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