# Programming contests

## 20 Programming Exercise for Beginners

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

# Lowest Numbers

Create a program that gives us the 10 smallest numbers of the input.

## Input Specification

The input consists of integer numbers between -1000 and +1000. Two consecutive numbers are separated by either a space or a newline character.

### Sample Input

1. `2 4 6 8 10 12 5`
2. `11 9 7 5 3 1 2`

## Output Specification

The output contains the smallest numbers, at most 10, in ascending order, separated by single spaces. Each number must appear only once, even if it occurs more than once on the input.

The output may contain less than 10 numbers only if less than 10 different numbers appeared on the input.

### Output for Sample Input

1. `1 2 3 4 5 6 7 8 9 10`

## Hints and Guide

The simplest data structure to calculate the result is a list implemented with an array. We recommend creating an `insert` function which manipulates the array as an ordered list of at most 10 integers.

The `insert` function must find the place of the next number in the ordered array by using a linear search. If the number is not present in the array and precedes the 10th number or the length of the array is less than 10, then it must be inserted.

One possible solution is available in: main.c.

### Possible Improvements

Inserting a number into an ordered array could have a high cost. To make the application faster, you can replace the array with a linked list.

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