home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / std / cplus / 1570 < prev    next >
Encoding:
Text File  |  1992-11-15  |  716 b   |  26 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!cs.ubc.ca!newsserver.sfu.ca!mtichy
  3. From: mtichy@fraser.sfu.ca (Martin Tichy)
  4. Subject: Shell Sort
  5. Message-ID: <1992Nov16.071937.12110@sfu.ca>
  6. Sender: news@sfu.ca
  7. Organization: Simon Fraser University, Burnaby, B.C., Canada
  8. Date: Mon, 16 Nov 1992 07:19:37 GMT
  9. Lines: 15
  10.  
  11. Can anyone please post or mail me a C++ shell sort?  I can't
  12. seem to get this one to work.
  13.  
  14. void shell_sort (int list[], int size)
  15. {
  16. int i, j, gap;
  17.  
  18. for ( gap = size / 2; gap > 0; gap /= 2)
  19.   for (i = gap; i < size; i++)
  20.     for (j = i - gap; j >= 0; j -= gap)
  21.       if (list [i] <= list [i+1]
  22.         break;
  23. swap ( &list [j], &list [j+1] );
  24. }
  25.  
  26.