标签:interview
// See http://www.hawstein.com/posts/19.1.html
// 19.1 Write a function to swap a number in place without temporary variables.
class CC19_1
{
void swap()
{
int a;
int b;
a = a + b;
b = a - b;
a = a - b;
}
// or
void swap()
{
int a;
int b;
a = a ^ b;
b = a ^ b;
a = a ^ b;
}
}标签:interview
原文地址:http://7371901.blog.51cto.com/7361901/1588252