标签:http nbsp blog block 不同 height log 交换 输入
1 ⊕ 1 = 0
0 ⊕ 0 = 0
1 ⊕ 0 = 1
0 ⊕ 1 = 1
简单说就是,相同为0,不同为1。
1 #include <iostream> 2 3 int main() 4 { 5 int a, b; 6 std::cout << "请输入要交换的两个数:"; 7 std::cin >> a >> b; 8 std::cout << "交换前:\na=" << a << " b=" << b << "\n"; 9 if (a == b) 10 { 11 } 12 else 13 { 14 a = a ^ b; 15 b = a ^ b; 16 a = a ^ b; 17 } 18 std::cout << "交换后:\na=" << a << " b=" << b << "\n"; 19 20 return 0; 21 }
标签:http nbsp blog block 不同 height log 交换 输入
原文地址:http://www.cnblogs.com/flatcc/p/6640932.html