如题:
有
int a =2;
int b =4;
两个变量,要求不使用第三变量就互换两变量值
java中有如下两种解决办法:
1:
a = a+b;
b = a-b;
a= a-b;
2:
a =a^b;
b =a^b;
a =a^b;
如题:
有
int a =2;
int b =4;
两个变量,要求不使用第三变量就互换两变量值
java中有如下两种解决办法:
1:
a = a+b;
b = a-b;
a= a-b;
2:
a =a^b;
b =a^b;
a =a^b;