// Version 4

// using statement with suitable semantics

#include <stdio.h>

void main()
{
    int data[] = {12, 3, 37, 8, 24, 15, 5, 33};
    int ndata = sizeof(data) / sizeof(int);
    int i, j;
    int min;
    int swapTmp;

    for (i=0; i<ndata; i++)
    {
        min = i;
        for (j=i+1; j<ndata; j++)
        {
            if (data[j]<data[min]) min = j;
        }
        swapTmp = data[min];
        data[min] = data[i];
        data[i] = swapTmp;
    }
    
    printf("Sorted data:\n");
    for (i=0; i<ndata; i++)
        printf(" %d", data[i]);
    printf("\n");
}