标签:blog ati class i++ rgs string pre 杨辉三角 sys
1 /** 2 * 杨辉三角 3 * @author chunzai 4 * 5 */ 6 public class Test1 { 7 public static void main(String[] args) { 8 int a[][] = new int[7][]; 9 for(int i=0;i<7;i++){ 10 a[i] = new int[i+1]; 11 for(int j=i;j<6;j++){ 12 System.out.print(" "); 13 } 14 for(int k=0;k<=i;k++){ 15 16 if(k==0||k==i){ 17 a[i][k] = 1; 18 19 }else{ 20 a[i][k] = a[i-1][k]+a[i-1][k-1]; 21 22 } 23 System.out.print(a[i][k]+" "); 24 } 25 System.out.println(); 26 } 27 } 28 }
标签:blog ati class i++ rgs string pre 杨辉三角 sys
原文地址:http://www.cnblogs.com/chunzai/p/6219359.html