Write a program that takes from the console an integer n and draws a vertical arrow with size as in the examples below.
The input is an odd integer n within the range [3 … 79].
Print a vertical arrow on the console, in which "
#" (number sign) marks the outline of the arrow, and "
." – the rest.
From the explanation we see that the input data will be read from one input line only, which will contain an integer within the range [3 … 1000]. This is why we will use a variable of
We can divide the figure into 3 parts – upper, middle and lower one. The upper part contains two sub-parts – a first row and a body of the arrow. We can see from the examples that the count of the outer dots on the first row and in the body of the arrow is
(n - 1) / 2. We can write this value in a variable
The number of the inside dots in the body of the arrow is
(n - 2). We must create a variable named
innerDots, which will store this value.
We can see from the examples the structure of the first row. We must use the declared and initialized variables
n, in order to print the first row.
In order to draw the body of the arrow, we need to create a loop, which runs
n - 2 times.
The middle of the figure is made of a beginning
#, a middle
. and an end
#. The number of
# is equal to
outerDots and that's why we can use the same variable again.
In order to draw the lower part of the arrow, we need to assign new values to the variables
new string can't join a symbol 0 times, the loop we are going to make must recur
n - 2 times and we need to print the last row of the figure separately. At each iteration
outerDots increases by 1, and
innerDots decreases by 2.
The last row of our figure is made of a beginning
., a middle
# and an end
.. The number of
Test your solution here: https://judge.softuni.org/Contests/Practice/Index/513#3.