Created
April 22, 2015 05:49
-
-
Save jongha/d24954e518d4f51dc5f1 to your computer and use it in GitHub Desktop.
Swap using XOR algorithm in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://en.wikipedia.org/wiki/XOR_swap_algorithm | |
private void Swap(ref int x, ref int y) | |
{ | |
x ^= y; | |
y ^= x; | |
x ^= y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment