Selection sort: each chosen minimum and every state

Produce a pass table with outer index i, selected minimum index before swapping, array after the pass, and whether a swap occurred. Give the exact output and count comparisons between array values separately from swaps. Explain what is guaranteed about the prefix after pass i+1, and why a strict < comparison keeps the first minimum in the current suffix. Here min is an index, not the minimum value.

#include <stdio.h>
int main(void) {
    int a[5] = {7, 3, 7, 1, 3};
    int comparisons = 0, swaps = 0;
    for (int i = 0; i < 4; ++i) {
        int min = i;
        for (int j = i + 1; j < 5; ++j) {
            ++comparisons;
            if (a[j] < a[min]) min = j;
        }
        if (min != i) {
            int temp = a[i]; a[i] = a[min]; a[min] = temp;
            ++swaps;
        }
        printf("pass=%d min=%d:", i + 1, min);
        for (int j = 0; j < 5; ++j) printf(" %d", a[j]);
        putchar('\n');
    }
    printf("comparisons=%d swaps=%d\n", comparisons, swaps);
    return 0;
}

