#include <iostream>
using namespace std;

int main()
{
    bool ok = true;
    const int arrsize = 10; 
    int x       // the input
        , n = 0 // to keep track of numbers already in the array
        , i, j  // to iterate in loops
        , arr[arrsize];

    cout << "Enter 10 numbers: \n";
    while (cin >> x) {
      	for (i=0, ok=false; i<n; i++ ) { // iterate for the general case
       	    if (x < arr[i]) {  // find first wher x is lower
       	        for (j = n; j>i; j--)  // move remaining elements
                    arr[j] = arr[j - 1];
                arr[i] = x;
                n++;
                ok = true;   // we've found the place and inserted x
                break; 
      	    }
       	}
       	if (!ok) {   // if we didn't insert until now, we have to add it at the end
       	    if (n<arrsize)
       	        arr[n++] = x; 
       	    else cerr << "Array full "<<endl; 
        }
    }

    for (i = 0; i < n; i++)  // n not 10 or arrsize
        cout << arr[i] << " ";

    // cin.get();
    //cin.get();
}