//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 2.18 on page 46

public class Pr0218
{ public static void main(String[] args)
  { double[] x = { 1.1, 2.2, 3.3, 4.4 };
    double[] y = { 2.0, 0.0, -1.0 };
    double[][] z = outerProduct(x,y);
    for (int i=0; i<x.length; i++)
    { for (int j=0; j<y.length; j++)
        System.out.print("\t" + z[i][j]);
      System.out.println();
    }
  }

  private static double[][] outerProduct(double[] x, double[] y)
  { double[][] z = new double[x.length][y.length];
    for (int i=0; i<x.length; i++)
      for (int j=0; j<y.length; j++)
        z[i][j] = x[i]*y[j];
    return z;
  } 
}
