include
using namespace std;
//Function prototype
int* selectSort(int ,int);
void showArray(const int [],int);
int main()
{
int array[] = {7,2,11,5,9,10};
int size = sizeof(array)/sizeof(array[0]);
showArray(array,size);
selectSort(array,size);
showArray(array, size);
cout <<array<< endl;
return 0;
}
int selectSort(int *p,int size)
{
for (int i=1;i<size;i++)
{
int t = (p + i);
int j;
for (j = i-1;j>=0&&t<(p+j);j--)
{
*(p + j+1) = *(p+j);
}
*(p + j + 1) = t;
}
return p;
}
void showArray(const int array[], int size)
{
for (int count=0;count<size;count++)
{
cout << array[count] <<" ";
}
cout << endl;
}