/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:12 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_dsort s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include #include #include "p_dsort.h" /* program DRDSORT *>> 1994-10-19 DRDSORT Krogh Changes to use M77CON *>> 1989-06-13 DRDSORT CLL Changed "dranua (r" to "dranua (d" *>> 1988-11-20 DRDSORT Snyder Initial code. *--D replaces "?": DR?SORT, ?SORT, ?SORTP, ?RANUA * * Test driver for DSORT and DSORTP. * * Construct an array of 1000 random numbers using DRANUA. * Sort it using DSORTP. * Check whether it is in order. * Sort it using DSORT. * Check whether it is in order. * */ int main( ) { LOGICAL32 ok; long int i, p[1000-(1)+1]; double x[1000-(1)+1]; /* Generate 1000 random numbers */ dranua( x, 1000 ); /* Sort them using DSORTP. Assume the sort will work. */ ok = TRUE; dsortp( x, 1, 1000, p ); /* Check the order. */ for (i = 2; i <= 1000; i++) { if (x[p[i-(1)]-(1)] < x[p[i - 1-(1)]-(1)]) ok = FALSE; } /* Print the results. */ if (ok) { printf("DSORTP succeeded\n"); } else { printf("DSORTP failed\n"); } /* Sort them using DSORT. Assume the sort will work. */ ok = TRUE; dsort( x, 1, 1000 ); /* Check the order. */ for (i = 2; i <= 1000; i++) { if (x[i-(1)] < x[i - 1-(1)]) ok = FALSE; } /* Print the results. */ if (ok) { printf("DSORT succeeded\n"); } else { printf("DSORT failed\n"); } exit(0); } /* end of function */