2011年4月1日 星期五

exchange the values of two variables

Let us consider another example. Usually when we want to exchange the values of
two variables, we do the following.

temp = a;
a = b;
b = temp;

Another way of doing this is as follows.

b ^= a ^= b ^= a;

沒有留言:

張貼留言