简单的杨辉三角,语法不抱错,但编译通过不了。求大神指点~~~
程序代码:
package Lianxi; public class LianXi14YangHuiSanJiao { /** * @param args */ public static void main(String[] args) { final int N = 10; int array[][] = new int [N][]; for (int i = 0; i < N; i++) { array[i] = new int[i];//定义该层数组大小 for (int j = 0; j <= i; j++) { if ((j == 0)||(j == i)) { array[i][j] = 1; }else { array[i][j] = array[i-1][j] + array[i-1][j-1]; } } } //打印出数组 for (int i = 0; i < array.length; i++) { for (int j = 0; j < array.length; j++) { System.out.println(array[i][j]+" "); } } } }