-
Notifications
You must be signed in to change notification settings - Fork 10
/
(week1) - mario(more) details.txt
73 lines (56 loc) · 1.78 KB
/
(week1) - mario(more) details.txt
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Toward the beginning of World 1-1 in Nintendo’s Super Mario Brothers, Mario must hop over adjacent pyramids of blocks, per the below.
Let’s recreate those pyramids in C, albeit in text, using hashes (#) for bricks, a la the below.
Each hash is a bit taller than it is wide, so the pyramids themselves are also be taller than they are wide.
# #
## ##
### ###
#### ####
The program we’ll write will be called mario. And let’s allow the user to decide just how tall the pyramids should be by first prompting them for a positive integer between, say, 1 and 8, inclusive.
Here’s how the program might work if the user inputs 8 when prompted:
$ ./mario
Height: 8
# #
## ##
### ###
#### ####
##### #####
###### ######
####### #######
######## ########
Here’s how the program might work if the user inputs 4 when prompted:
$ ./mario
Height: 4
# #
## ##
### ###
#### ####
Here’s how the program might work if the user inputs 2 when prompted:
$ ./mario
Height: 2
# #
## ##
And here’s how the program might work if the user inputs 1 when prompted:
$ ./mario
Height: 1
# #
If the user doesn’t, in fact, input a positive integer between 1 and 8, inclusive, when prompted, the program should re-prompt the user until they cooperate:
$ ./mario
Height: -1
Height: 0
Height: 42
Height: 50
Height: 4
# #
## ##
### ###
#### ####
Notice that width of the “gap” between adjacent pyramids is equal to the width of two hashes, irrespective of the pyramids’ heights.
Modify mario.c at right in such a way that it implements this program as described!
How to Test Your Code
Does your code work as prescribed when you input
-1 (or other negative numbers)?
0?
1 through 8?
9 or other positive numbers?
letters or words?
no input at all, when you only hit Enter?