#K33337. Temperature Trend Analysis
Temperature Trend Analysis
Temperature Trend Analysis
You are given several datasets of temperature readings. Each dataset is represented by a line of space-separated integers, and the input terminates with a line containing only a single zero (0
), which should not be processed. For each dataset, determine the temperature trend according to the following rules:
- INCREASING: Every number is strictly less than the next one. Formally, for a sequence \(a_1, a_2, \dots, a_n\), it is increasing if \(a_1 < a_2 < \dots < a_n\).
- DECREASING: Every number is strictly greater than the next one. That is, \(a_1 > a_2 > \dots > a_n\).
- CONSTANT: All numbers in the sequence are the same, i.e. \(a_1 = a_2 = \dots = a_n\).
- NO TREND: If the sequence does not fit any of the above categories.
Your task is to write a program that reads from standard input and prints the trend of each dataset to standard output. Each result should be printed on a new line in the same order as the input datasets.
inputFormat
The input consists of multiple lines. Each line (except the last) contains a dataset represented as a series of space-separated integers, denoting temperature readings. The input terminates with a line containing a single 0
. You should not process the terminating line.
outputFormat
For each dataset provided in the input, output one line with one of the following strings: INCREASING
, DECREASING
, CONSTANT
, or NO TREND
, as determined by the rules above.
10 20 30 40
40 30 20 10
15 15 15
20 20 30 30
0
INCREASING
DECREASING
CONSTANT
NO TREND
</p>