+ 1
Find the largest and smallest number in an array and swap those numbers without using functions method.
Print the array by swapping only smallest and largest element. Please help me solve this.
5 Answers
+ 4
Sort the array, before swapping the first and last element.
+ 4
This is a starting point:
https://code.sololearn.com/c63K169QjJhh/?ref=app
And then, I'd recommend you traversing the array with a range based reference for loop and storing references to min and max. You can then call my function with these and you're done.
+ 2
My suggested solution is generic so that the question of Luciano Ariel Caputi would not matter.
+ 2
Jay Matthews That's what I just said.
+ 1
How is the array?
1) 24513 => min = 1 / max = 5
2) "home" "car" "years" "yellow" "tomorrow" => min = "car" / max = "tomorrow"