-
Notifications
You must be signed in to change notification settings - Fork 15
/
mario-more.c
38 lines (36 loc) · 871 Bytes
/
mario-more.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int height = 0;
// Keeps getting height input from the user until it is between 1 and 8 inclusive
do
{
height = get_int("Height: ");
}
while (height < 1 || height > 8);
// For each row
for (int i = 0; i < height; i++)
{
// For each column
for (int j = 1; j < height - i; j++)
{
// Prints preceding spaces
printf(" ");
}
for (int x = -1; x < i; x++)
{
// Prints the required number of hashes
printf("#");
}
// 2 spaces of gap
printf(" ");
for (int y = -1; y < i; y++)
{
// Second set of hashes that are symmetrical to the first
printf("#");
}
// Next row (new line)
printf("\n");
}
}