首页 > 技术文章 > 位运算两数交换
jecyhw 2015-03-26 15:42 原文
void swap(int &a, int &b) { a ^= b;//a = (a^b) b ^= a;//b = b^(a^b)=0^a=a a ^= b;//a = (a^b)^a=b }