首页  编辑  

交换两个整数变量经典语句

Tags: /C#/算法/   Date Created:

int a = int . MaxValue;

int b = int . MinValue;

a = b | (b = a) & 0 ;

b = a + (a = b) * 0 ;

a ^= b ^ (b ^= a ^ b);

Console . WriteLine( string . Format( "a={0},b{1}" , a, b));