When you are programming, you will write something like
to swap the values of two variables x
and y
. What is you are out of memory and cannot declare a new variable z
, are you able to do it?
You need: handout
x
and y
.x
and y
.Although we say there are three rules for row operations, but Rule 1 can actually be replaced by a sequence of Rule 2 and Rule 3 . Using this idea, one may obtain the algorithm for swapping two variables.
int
variable can only handle integers from . Adding big numbers, as we did in the algorithm, can potentially cause integer overflow. How can we deal with this issue?