// 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; } }
时间: 2024-11-09 00:13:14