若a1 = 10,a2 = 20,求让a1= 20,a2 = 10:
方法一:
var a1=10; var a2=20; a3=a1; a1=a2; a2=a3;
方法二:
a1=a1+a2; a2=a1-a2; a1=a1-a2;
方法三:
a=a^b; b=a^b; //b = a^b^b a=a^b; //a = a^a^b