20170801 JAVA输出杨辉三角(非等腰三角形)

package com.chy.array;

public class Ex6 {
public static void main(String[] args) {
int a[][] = new int[6][6];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
if (j == 0 || i == j) {
a[i][j] = 1;
} else {
if (i > j) {
a[i][j] = a[i – 1][j] + a[i – 1][j – 1];
}
}
}
}
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
if (i >= j) {
System.out.print(a[i][j] + “\t”);
}
}
System.out.println();
}
}
}

    原文作者:杨辉三角问题
    原文地址: https://blog.csdn.net/xcwc1995/article/details/76551949
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞