int a=1,b=2;
b=a+(a=b)-a;
//以上语句相当于以下三步:
//b=a+b;
//a=b;
//b=b-a;
System.out.println(a +"," + b);
a=1;
b=2;
b=a*b/(a=b/a);
System.out.println(a +"," + b);
a=1;
b=2;
a=a^b;
b=a^b;//利用异或的特性,某数对另一数双次异或后返回原数
a=a^b;//同理
System.out.println(a +"," + b);
网友评论