-
Notifications
You must be signed in to change notification settings - Fork 0
/
mario.c
53 lines (49 loc) · 829 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
53
#include <cs50.h>
#include <stdio.h>
int get_height(void);
void right_aligned_pyramid(int height);
//void left_aligned_pyramid(int height);
int main(void)
{
int n = get_height();
right_aligned_pyramid(n);
//left_aligned_pyramid(n);
}
int get_height(void)
{
int n;
do
{
n=get_int("Size: ");
}
while (n<1||n>8);
return n;
}
void right_aligned_pyramid(int height)
{
for (int i=height;i>0;i--)
{
for (int j=0;j<i-1;j++)
{
printf(" ");
}
for (int m=0;m<height-i+1;m++)
{
printf("#");
}
printf("\n");
}
}
/*
void left_aligned_pyramid(int height)
{
for (int i=0;i<height;i++)
{
for (int j=0;j<i+1;j++)
{
printf("#");
}
printf("\n");
}
}
*/