Swapping (Was: Re: Brain Teaser)
Bjorn Engsig
bengsig at oracle.nl
Thu Mar 29 17:45:38 AEST 1990
Please folks, this is discussed ever so often here, the various "strange"
ways of doing swapping (three step add/subtract or xor) are all potentially
risky: add/subtract might overflow, xor doesn't work if you swap two
variables that are actually the same, they only work with integers (NOT,
repeat NOT with pointers), etc, etc. Swapping is done just like you swap
two piles of paper on your desk with one hand: using temporary storage.
--
Bjorn Engsig, Domain: bengsig at oracle.nl, bengsig at oracle.com
Path: uunet!mcsun!orcenl!bengsig
More information about the Comp.lang.c
mailing list