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