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