/* test_heapsort.c */ #include #include #include #include "heapsort.h" extern int countcmp, countintr; /* from heapsort.h */ /* sample user program with a data structure and call on heapsort */ struct elem_type {char key[6]; int tag;} array[] = { "mmmmm",0, "aaaaa",1, "ccccc",2, "ddddd",3, "bbbbb",4, "zzzzz",5, "yyyyy",6, "xxxxx",7, "uuuuu",8, "nnnnn",9, "ppppp",10,"qqqqq",11,"rrrrr",12,"sssss",13,"ttttt",14, "eeeee",15,"fffff",16}; static int num = 16; static int width = sizeof(struct elem_type); static double vecd[6] = {3.0, 5.0, 1.0, 6.0, 2.0, 4.0}; static int veci[6] = {4, 5, 1, 6, 2, 3}; static int compare(void *elem1, void *elem2); /* strings */ static int compd(void *elem1, void *elem2); /* doubles */ static int compint(void *elem1, void *elem2); /* ints */ int main(int argc, char *argv[]) { int i, n; printf("test_heapsort.c various arrays and statistics \n"); n = 6; printf("before sort of n=%d integers \n",n); for(i=0;i