杨辉三角
package lianxi; public class Yanghuisanjiao { public static void main(String[] args) { int[][] ary =new int[10][10]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10-i; j++) { System.out.print(" "); } for (int k = 0; k < i+1; k++) { if(k==0||k==i) { ary[i][k]=1; System.out.print(" "+ary[i][k]+" "); continue; } else { ary[i][k]=ary[i-1][k-1]+ary[i-1][k]; System.out.print(" "+ary[i][k]+" "); } } System.out.println(); } } }