/* test2_heapsort.c sort array x,y,z closest to xp,yp,zp*/ #include #include #include #include "heapsort.h" /* sample user program with a data structure and call on heapsort */ typedef struct {double x; double y; double z;} xyz; static xyz vert[6] = {{ 1.0, 1.0, 1.0}, { 2.0, 1.0, 1.0}, { 1.0, 2.0, 1.0}, { 1.0, 1.0, 2.0}, { 2.0, 2.0, 2.0}, { 2.0, 2.0, 1.0}}; double xp = 1.6; double yp = 1.8; double zp = 1.7; static int compd(void *elem1, void *elem2); /* using distance */ static double dist(double x, double y, double z, double xp, double yp, double zp); int main(int argc, char *argv[]) { int i, n; printf("test2_heapsort.c 3D data with 4th key \n"); n = 6; printf("before sort of n=%d doubles \n",n); printf("pt %f %f %f\n", xp, yp, zp); for(i=0; i