1 package com.llh.demo; 2 3 /** 4 * 杨辉三角 5 * 6 * @author llh 7 * 8 */ 9 public class Test { 10 /* 11 * 杨辉三角 12 */ 13 public static void main(String[] args) { 14 int[] a = new int[11]; 15 int num = 1; 16 // 17 for (int i = 1; i <= 10; i++) { 18 for (int j = 1; j <= i; j++) { 19 int c = a[j]; 20 a[j] = num + c; 21 num = c; 22 System.out.print(a[j] + " "); 23 } 24 System.out.println(); 25 } 26 } 27 28 }