0
For loop for array to exchange elements of array?
3 Respuestas
+ 1
A hint (I have to go offline for a little while).
This works in Python:
a,b = 1,2 (assigns both at once)
so does this:
myList[i],myList[j] = myList[j],myList[i]
for swapping in place without a temporary variable.
+ 1
It's not a loop Kirk
Maybe Atef can add some words in question. What do you mean about exchange here?
+ 1
Wish I could get a list of threads I was following.
It wasn't supposed to provide the answer, since the structure of the array isn't specified. I might have just said "show the array" but I felt a quick boost was more helpful.
The exchange shown should actually make the resulting loop less complex. Trouble with that should have (I hoped) resulted in more detail as you've asked.