import edu.gwu.stat.*; public class MaxDifference1 { static double[] makeRandomArray (int length) { double[] A = new double [length]; for (int i=0; i max) { // 3.1.1 If so, record the new maximum and the values // that achieved it. max = diff; x = A[i]; y = A[j]; } } // inner-for } // outer-for // 4. Output: System.out.println ("Algorithm 1: the numbers: " + x + "," + y + " difference=" + max); } public static void main (String[] argv) { if ( (argv == null) || (argv.length == 0) ) { System.out.println ("Usage: java StringComparison "); // System.exit(0); } try { int length = Integer.parseInt (argv[0]); double[] A = makeRandomArray (length); long startTime = System.currentTimeMillis(); algorithm1 (A); double timeTaken = System.currentTimeMillis() - startTime; System.out.println ("Algorithm 1: timeTaken=" + timeTaken); } catch (Exception e) { System.out.println (e); //e.printStackTrace(); } } }