/* File: t_selection.c Test the Selection Sort routines */ #include #include "sorting.h" main(int argc, char *argv[]) { data *A ; index i, n ; if (argc != 2) { fprintf(stderr, "Usage: t_selection filename\n") ; exit(1) ; } n = readarray(argv[1], &A) ; if ( n <= 0 ) { fprintf(stderr, "oops, can't read\n" ) ; exit(1) ; } selection_sort(A,0,n-1) ; #ifndef NDEBUG if (!checkarray(A,n)) { printf("Sorting routine INCORRECT!\n") ; } printarray(A,n) ; #endif }