-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmario.c
52 lines (45 loc) · 846 Bytes
/
mario.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
47
48
49
50
51
52
#include <stdio.h>
#include <cs50.h>
int main(void)
{
// Prompts user for number
int height;
do
{
height = get_int("Height: ");
}
while (height < 1 || height > 8);
// Prints pyramid
int space = height - 1;
int hash = 1;
int width = 1;
while (hash <= height)
{
// SPACES
while (space > 0)
{
printf(" ");
space--;
}
// LEFT HASHES
width = hash;
while (hash > 0)
{
printf("#");
hash--;
}
hash = width;
// GAP
printf(" ");
//RIGHT HASHES
while (hash > 0)
{
printf("#");
hash--;
}
// NEW LINE
printf("\n");
hash = width + 1;
space = height - hash;
}
}