for ( int i = 0; i < 4; i++ )
{
int min = i;
for ( int j = i + 1; j < 5; j++ )
{
if ( arry[min] < arry[j] ) min = j;
}
if ( min != i )
{
int tmp = arry[i];
arr[i] = arr[min];
arr[min] = tmp;
}
}
At first we suppose that the minimum element is the first element of the sub sequence. So we remember its position that to compare this element with other elements in the subsequence.