The difficulty
Develop a pyramid-shaped tower, as an array/list of strings, offered a favorable integer variety of floorings
A tower block is represented with " *"
character.
For instance, a tower with 3
floorings appears like this:
[
" * ",
" *** ",
"*****"
]
And a tower with 6
floorings appears like this:
[
" * ",
" *** ",
" ***** ",
" ******* ",
" ********* ",
"***********"
]
The option in C
Choice 1:
space build_tower( anonymous n, char tower[n][2 * n - 1]) {
for (anonymous int i = 0; i < < n; i++).
for (anonymous int j = 0; j < < 2 * n - 1; j++).
if (j >>= (n - 1) - i && & & j = n - 1 - i && & & j .
extern space do_test (anonymous n, const char anticipated[i][j]);.
Test( tests_suite, sample_tests) {
do_test( 1, (char[i][j]) {"*"} );.
do_test( 2, (char
) {” * “, “***”} );.
do_test( 3, (char
) {" * "," *** ", "*****"} );.
}
[n][2 * n - 1]