0
The problem is finding the smallest and largest number of 10 inputs. Then swap the position of the largest and the smallest num
Do anyone know's a more efficient way of programming this? https://code.sololearn.com/crMtzxDa0jia/?ref=app
2 Réponses
+ 3
NPCcode
one way is you can save the indexes also, no need for comparison again.
+ 3
NPCcode you can perform the smallest/largest comparison during the input loop. It does not have to be in a separate loop. Use Tina 🕊🇺🇦🇮🇷's recommendation, too, so then you can remove two of the three loops. When the input loop is done, swap the values according to their indices.