Arrays in C
Implement a function that finds the smallest and the largest
elements in an integer array of n elements, and
swaps them.
For
example, array = {1, 2, 3} and n = 3,
after calling the function
the array becomes array = {3, 2, 1}.
/**
* \brief Finds the maximum and the minimum value of an
array composed of n elements
* and swaps them.
*
* \details The function finds the maximum and minimum
element in the argument
* array, and then swaps
them.
*
* For example, array =
{1, 2, 3} and n = 3, after calling the function
* array = {3, 2, 1}.
*
* \param array An array of n integer elements
* \param n The number of elements in array
*
* \note A function for swapping two values is provided
above.
*
* \note In your implementation, do not write to stdout to
check the functionality.
* You should use my_tests function to
print and check the functionality
* of your implementation.
*/
void swap_min_max(int* array, unsigned int n)
{
//TODO: implement your function here!
}
Arrays in C Implement a function that finds the smallest and the largest elements in an integer array of n elements, and swaps them. For example, array = {1, 2, 3} and n = 3, after calling the function the array becomes array = {3, 2, 1}. Hint A function for swapping two values is provided in the template.
Arrays in C Implement a function that finds the smallest and the largest elements in an integer array of n elements, and
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am