Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example 1
- // Does not swap values (some of them inside the braces may return 0)
- my_array[i] ^= (my_array[i-1] ^= (my_array[i] ^= my_array[i-1]));
- // Example 2
- // Works fine, just requires more lines, although it's the exact same technique as above
- my_array[i] ^= my_array[i-1];
- my_array[i-1] ^= my_array[i];
- my_array[i] ^= my_array[i-1];
Advertisement
Add Comment
Please, Sign In to add comment