Celmomether
A thermometer measures the temperature at regular intervals and stores the measured temperatures (may be also negative) in the temperatures
array of integers (the int
type). Unfortunately, the device is somewhat unreliable, so sometimes it is not able to measure the temperature. In that case, the value stored in the array is equal to no_value
constant.
Display the measured values in the array on the standard output as a horizontal bar thermometer. Each measured value will be displayed on one line. The first column of the output represents the most negative measured value (ignore no_value
constant). Each additional column of the output represents a temperature 1 degree higher. The temperature will be displayed as a continuous segment of the characters *
from the column representing the measured temperature to the column representing the temperature 0. Space characters are used for padding of the unused columns on the left side. If a value corresponding to the constant no_value
appears in the measured values, then the last actually measured value is used instead (use 0 if there is no such value).
To simplify the input, insert the following two lines into your source code and use them as input array for measured values
constexpr int no_value = -999;
int temperatures[] { 10, 12, no_value, no_value, 20, 14, 6, -1, -5, 0, no_value, 1, -3 };
Demo output for values -1, no_value, -3, 0, 2
:
**
**
****
*
***