标签:
public class Main { double a[][] = new double[][]{{2, 1, 5}, {4, 1, 12}, {-2, -4, 5}}; public static void main(String[] args) { new Main(); } Main() { for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[0].length; j++) { for (int k = 0; k < Math.min(i, j); k++) { a[i][j] -= a[i][k] * a[k][j]; } if (i > j) a[i][j] /= a[j][j]; } } for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[0].length; j++) { System.out.print(" " + a[i][j]); } System.out.println(); } } }
标签:
原文地址:http://www.cnblogs.com/weidiao/p/5921201.html