forked from LuanDevecchi/HacktoberfestAlgo2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMario_more.c
46 lines (38 loc) · 935 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
39
40
41
42
43
44
45
46
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// ask for a number
int h = 0;
printf("How many steps high is the pyramid? ");
h = get_int();
while (h < 0 || h > 23)
{
printf("The height must be a whole number between zero and 24. Try again: ");
h = get_int();
}
// on each row
for (int i = 0; i < h; i++)
{
// print leading spaces
for (int s = 0; s < h - i - 1; s++)
{
printf(" ");
}
// print left-side hashtags
for (int x = h - i - 1; x <= h; x++)
{
printf("#");
}
// print gap
printf(" ");
// print right-side hashtags
for (int x = h - i - 1; x <= h; x++)
{
printf("#");
}
// move to new line
printf("\n");
}
return 0;
}