#include<stdio.h>
void printfArr(int arr[],int len)
{
for(int i = 0; i < len; i++)
{
printf("%d\t",arr[i]);
}
}
void minToMax(int arr[],int len)
{
for(int i = 0; i < len-1; i++)
{
int min = arr[i];
int minIndex = i;
for(int j = i+1; j < len; j++)
{
if(arr[j] < min)
{
min = arr[j];
minIndex = j;
}
}
arr[minIndex] = arr[i];
arr[i] = min;
}
return;
}
void maxToMin(int arr[],int len)
{
for(int i = 0; i < len-1; i++)
{
int max = arr[i];
int maxIndex = i;
for(int j = i+1; j < len; j++)
{
if(arr[j] > max)
{
max = arr[j];
maxIndex = j;
}
}
arr[maxIndex] = arr[i];
arr[i] = max;
}
return;
}
int main()
{
int arr[] = {5,7,6,9,1,3};
minToMax(arr,sizeof(arr)/sizeof(1));
printfArr(arr,sizeof(arr)/sizeof(1));
maxToMin(arr,sizeof(arr)/sizeof(1));
printfArr(arr,sizeof(arr)/sizeof(1));
}