-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmario.c
50 lines (45 loc) · 895 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
#include <cs50.h>
#include <stdio.h>
//funcao responsavel pelo espaco
void espaco(int m);
//funcao responsavel pelo #
void bloco(int n);
int main(void)
{
int height;
int andar = 1;
//pergunta a altura da torre dentro do valor válido
do
{
height = get_int("Heigth: ");
}
while (height < 1 || height > 8);
int space = height - 1;
//chama as funcoes para construir o próximo andar da torre e atualiza as variaveis
do
{
espaco(space);
bloco(andar);
printf(" ");
bloco(andar);
printf("\n");
andar++;
space--;
height--;
}
while (height > 0);
}
void bloco(int n)
{
for (int j = 0; j < n; j++)
{
printf("#");
}
}
void espaco(int m)
{
for (int i = 0; i < m; i++)
{
printf(" ");
}
}