home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_04
/
1104111a
< prev
next >
Wrap
Text File
|
1993-02-05
|
512b
|
32 lines
/* select1.c: Illustrate selection sort */
#include <stdio.h>
#define NELEMS 4
main()
{
int a[NELEMS] = {40, 12, 37, 15};
size_t i, j;
for (i = 0; i < NELEMS-1; ++i)
for (j = i+1; j < NELEMS; ++j)
if (a[i] > a[j])
{
int t = a[i];
a[i] = a[j];
a[j] = t;
}
for (i = 0; i < NELEMS; ++i)
printf("%d\n",a[i]);
return 0;
}
/* Output:
12
15
37
40
*/