You're using the solution as it is because you can't 'return' two variables from a function, just the one, so you have to pass them around by reference rather than by value (which is more of a copy function).
If you could return two variables...it would look something like this
1 2 3 4 5
int swap ( int x , int y )
return ( int y , int x ); //This isn't possible however.
You MIGHT be able to use a list or an an array to achieve something similar but it's easier and more efficient to just pass by ref.