杨辉三角

package 杨辉三角;
import java.util.Scanner;
public class 杨辉三角 {
public static void main(String[] args) {
int rows = 5;

for(int i =0;i<rows;i++) {
int number = 1;

System.out.format("%"+(rows-i)*2+"s","");
for(int j=0;j<=i;j++) {
System.out.format("%4d",number);
number = number * (i - j) / (j + 1);
}
System.out.println();
}
}
}

 

posted on 2018-04-02 19:26  小小青&#127800;  阅读(112)  评论(0编辑  收藏  举报