-
Notifications
You must be signed in to change notification settings - Fork 0
/
mario.c
42 lines (36 loc) · 777 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
//CS50 Lecture 2 Mario.c IDE https://sandbox.cs50.io
#include <cs50.h>
#include <stdio.h>
int get_positive_int(string prompt);
int main(void)
{
//Get "Height" from user
int n = get_positive_int("Height:");
int i, j;
//Nested loops
{
for (i = 0; i < n; i++)
{
for (j = 0; j > i - n + 1; j--)
{
printf(" ");
}
for (j = 0; j <= i + 1; j++)
{
printf("#");
}
printf("\n");
}
}
}
//Function get Height from user until it will fit between 1 & 7
int get_positive_int(string prompt)
{
int n;
do
{
n = get_int("%s", prompt);
}
while (n > 8 || n < 1);
return n;
}