int a = 1;
int b = 2;
cout << "a: "<< a << endl;
cout << "b: "<< b << endl;
a = a ^ b;
b = a ^ b;
a = a ^ b;
cout << "a: " << a << endl;
cout << "b: " << b << endl;
C++取反交换两个数的值
最新推荐文章于 2024-03-24 18:25:08 发布
int a = 1;
int b = 2;
cout << "a: "<< a << endl;
cout << "b: "<< b << endl;
a = a ^ b;
b = a ^ b;
a = a ^ b;
cout << "a: " << a << endl;
cout << "b: " << b << endl;