The problem is how to exchange values between vairiable a and variable b. To more clearly see the following example:
The initial state:
The initial state:
From the example image above, how to swap the value of the variable b to be 721, and the alue of a variable to 463.
To get a result as above, we can not directly attached to the alue of the variable b to a, and a to b, if we take this way, there will be:
This happened because, when the value of variable b is copied to a variable b the value of the old into the new value of a variable, then the new value of a variable copied to b, the result is the value of the variable b, same as the old value of the variable b.
Anyway is to make the variable t (new variable):
We can copy the value of a variable to t, then the value is copied into a variable b, then value of the variable t copied to b.
Posted by 07.01 and have
0
comments
, Published at