~cpp
import java.util.Scanner;
public class Number
{
final int MAX_SIZE = 100000;
final int SENTINEL_NUM = -999;
private int elements[];
private int length;
public Number()
{
elements = new int[MAX_SIZE];
length = 0;
}
public void inputNumber()
{
Scanner input = new Scanner(System.in);
for (int i = 0; i < MAX_SIZE; i++)
{
elements[i] = input.nextInt();
if (elements[i] == SENTINEL_NUM)
break;
else
length++;
}
}
public int findMidiumNumber()
{
sortElement(0, length);
int mid = (int)Math.floor(0.5 * length + 0.5);
return elements[mid - 1];
}
public void sortElement(int start, int end)
{
int min;
for (int i = start; i < end - 1; i++)
{
min = i;
for (int j = i + 1; j < end; j++)
{
if (elements[min] > elements[j])
min = j;
}
swapElement(i, min);
}
}
public void swapElement(int i, int j)
{
int t = elements[i];
elements[i] = elements[j];
elements[j] = t;
}
}