Exchange a,b without using other variables

there are two ways:
1:
a=a+b;
b=a-b;
a=a-b;
//in this case,  if a or b is a very big number, a+b maybe will overflow.

2:
a=a^b;
b=a^b;
a=a^b;

posted on 2008-02-26 08:42  飞天舞者  阅读(199)  评论(0编辑  收藏  举报

导航

For more information about me, feel free email to me winston.he@hotmail.com