Skip to content

Instantly share code, notes, and snippets.

@voidnerd
Created April 11, 2020 02:41
Show Gist options
  • Save voidnerd/d009daad8c617656e5166c20d9f777fd to your computer and use it in GitHub Desktop.
Save voidnerd/d009daad8c617656e5166c20d9f777fd to your computer and use it in GitHub Desktop.
A solution for Harvard / edX CS50 week 1 Mario World 1-1
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int n;
do {
n = get_int("height: ");
}while(n < 1 || n > 8);
int k = n * 2;
int x = 1;
for (int i = n; i > 0; i--) {
for (int j = 1; j <= k; j++) {
if(j == n) {
printf("# ");
}else if (j < n) {
if(j < i && j < n) {
printf(" ");
}else {
printf("#");
}
}else {
if( j - n <= x) {
printf("#");
}
}
}
x++;
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment