Re: bubble sort
"William Rance" <[email protected]>
| Newsgroups | gmane.comp.programming.cppug |
|---|---|
| Message-ID | <000101c3a296$c772f5e0$5e5518d2@pcmaster> |
Sorry this message was sent to wrong address ----- Original Message ----- From: "William Rance" <[email protected]> To: <[email protected]> Sent: Tuesday, November 04, 2003 1:14 PM Subject: bubble sort > John, > Your swap() is call by value i.e. it makes a copy of the value, thus it > will not affect the arguments in the routine which called it;- I would > propose you to make your > swap() call by reference i.e.calling program passes 'pointers' to the values > to be changed- > n.b.1)swap returns two values, the new values of its arguments. > 2)there is a strong relationship between 'pointers' and arrays, so we can > treat them simultaneously. > > swap(&a, &b) > int *pa, *pb; > { > int t; > t = *pa; > *pa = *pb; > *py = t; > } > > Bill > ------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511 http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/EbFolB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/