How to Develop a Tower in C

The difficulty

Develop a pyramid-shaped tower, as an array/list of strings, provided 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 service in C

Alternative 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]

Like this post? Please share to your friends:
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: