#include <iostream>
using namespace std;
 
void selectionSort(int *array, int size);
 
int main()
{
        // create array and initialize with values
        int size = 0;
        cout << "How many integers do you want to enter? ";
        cin >> size;
 
        int* array = new int[size];
 
        cout << "Enter a list of " << size << " integers: " <<endl;
        for (int i = 0; i < size; i++)
               cin >> array[i];
 
        // sort the array
        selectionSort(array, size);
 
        // display the sorted array
        for (int j = 0; j < size; j++)
               cout << array[j] << ' ';
        cout << endl;
 
        return 0;
}
 
 
void selectionSort(int *array, int n)
{
        int imax = 0;
        for (int size = n; size > 1; size--)
        {
               for (int i = 1; i < size; i++)
                       if (array[imax] < array[i])
                               imax = i;
               int temp = array[imax];
               array[imax] = array[size-1];
                array[size-1] = temp;
               imax = 0;
        }
}
 
 

syntax highlighted by Code2HTML, v. 0.9.1