bubble sort

"William Rance" <[email protected]>
Newsgroups gmane.comp.programming.cppug
Message-ID <004801c3a292$7cda1da0$a95d18d2@pcmaster>
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.