#include #include #define true 1 #define false 0 #define and && #define or || #define boolean int #define sqr(a) ((a)*(a)) #define INFINITY_LONG 10000000L static r_seed = 12345678L; double uniform () { static long m = 2147483647; static long a = 48271; static long q = 44488; static long r = 3399; long t, lo, hi; hi = r_seed / q; lo = r_seed - q * hi; t = a * lo - r * hi; if (t > 0) r_seed = t; else r_seed = t + m; return ( (double) r_seed / (double) m ); } double* makeRandomArray (int length) { int i; double *A = (double*) malloc (sizeof(double) * length); for (i=0; i max) { max = diff; x = A[i]; y = A[j]; } } } printf ("Algorithm 1: the numbers: %lf,%lf difference=%lf\n", x, y, max); } int main () { double *A; int i; A = makeRandomArray (10000); algorithm1 (A, 10000); }