#include
using std::cout;
using std::endl;
void move(int*, const int);
void print(const int*, const int);
int main()
{
const int arraySize = 10;
int a[arraySize] = { 4, 7, 3, 9, 2, 1, 8, 6, 5, 10 };
cout << "Array before modify:" << endl;<br> print(a, arraySize);
move(a, arraySize);
cout << "\nArray after modify:" << endl;<br> print(a, arraySize);
return 0;
}
void print(const int *a, const int size)
{
for(int i = 0; i < size; i++)
{
cout << a[i] << ' ';<br> }
cout << endl;<br>}
void move(int *a, const int size)
{
int smallest = 0;
int largest = 0;
int temp;
for(int i = 1; i < size; i++)
{
if(a[smallest] > a[i])
{
smallest = i;
}
if(a[largest] < a[i])
{
largest = i;
}
}
temp = a[smallest];
a[smallest] = a[largest];
a[largest] = temp;
}