C++ 用宏实现swap(a,b)
#include <iostream>
using namespace std;
#define SWAP(a,b) a^=b,b^=a,a^=b
int main(void){
int x = 2,y=3;
SWAP(x,y);
cout << x << ',' << y << endl;
return 0;
}
#include <iostream>
using namespace std;
#define SWAP(a,b) a^=b,b^=a,a^=b
int main(void){
int x = 2,y=3;
SWAP(x,y);
cout << x << ',' << y << endl;
return 0;
}