访问量: 28975次,访客数: 24458人,浏览量: 1次 
首页  编辑  

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

Tags: /C#/算法/   Date Created: Tue Jun 10 2008 01:17:52 GMT+0000 (Coordinated Universal Time)

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));