Programming contests

50 Programming Exercise for Beginners

January 2, 2019 12:00 AM – December 31, 2019 12:00 AM

Monotonicity

Write a program that reads integers from the standard input. The first number of each line determines how many additional numbers are given in that line. For each line, determine whether the sequence from the second number to the end of the line is monotonous, and if so, write „monoton” (monotonous in Hungarian), otherwise „nem monoton” (nonmonotonous in Hungarian) to the standard output.
One-element and two-element sequences are considered monotonous. The input is terminated by a line containing only one 0, this line should not be processed.

Sample Input

  1. 10 1 1 1 1 1 2 2 2 2 2
  2. 3 2 3 2
  3. 3 3 3 2
  4. 1 0
  5. 4 -1 0 1 0
  6. 0
download as text file

Output for Sample Input

  1. monoton
  2. nem monoton
  3. monoton
  4. monoton
  5. nem monoton
download as text file

One possible solution is available in: main.c.

Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
University of Debrecen; Faculty of Informatics; v. 03/01/2019