//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 2.20 on page 46

public class Pr0220
{ public static void main(String[] args)
  { double[][] x = { { 1.0, 2.0, 3.0 },
                     { 4.0, 5.0, 6.0 } };
    double[][] y = transpose(x);
    for (int i=0; i<y.length; i++)
    { for (int j=0; j<y[0].length; j++)
        System.out.print("\t" + y[i][j]);
      System.out.println();
    }
  }
  private static double[][] transpose(double[][] x)
  { double[][] y = new double[x[0].length][x.length];
    for (int i=0; i<x[0].length; i++)
      for (int j=0; j<x.length; j++)
        y[i][j] = x[j][i];
    return y;
  } 
}
