But how is that going to work for objects? On Mon, Nov 5, 2012 at 6:43 AM, Ashok Varma <verma....@gmail.com> wrote:
> Try this: a = a + b - (b = a); //single line code to swap > > > > > On Mon, Nov 5, 2012 at 4:53 AM, Dave <dave_and_da...@juno.com> wrote: > >> @Manish: Sure. >> >> a = a + b; >> b = a - b; >> a = a - b; >> >> In 2-s complement arithmetic, it works even if a + b overflows. >> >> Dave >> >> On Sunday, November 4, 2012 2:32:43 PM UTC-6, manish wrote: >> >>> Swapping two objects (not integers/chars),without using temp...? >>> my solution is using xor operation..is that right and ny other solutions >>> ? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/algogeeks/-/nc5h3uIL65AJ. >> >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Umer -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.