/* 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
*/
/* End of File */