Programming contests

50 Programming Exercise for Beginners

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

Divisibility Testing

Write a program that reads two positive integers per line from the standard input until the first number is greater than the second. For each line, the program should output those numbers between the two integers scanned that are divisible by 3, but not divisible by 9, separated by exactly one space character. If there are no such numbers between the two integers, –1 should be displayed in the output. Immediately after the last number in each line, the newline character should appear (without an extra space).

Sample Input

  1. 10 20
  2. 10 10
  3. 12 12
  4. 1 2
  5. 2 1
download as text file

Output for Sample Input

  1. 12 15
  2. -1
  3. 12
  4. -1
download as text file

Possible solutions: main1.c and main2.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