//打印杨辉三角形。
import java.util.Scanner;
public class Yanghui_Triangle{
public static void main(String args[]){
//输入行数
Scanner scan= new Scanner(System.in);
System.out.println("请输入杨辉三角形行数:");
int row = scan.nextInt();
int yanghui[][]= new int[row][];
System.out.println("杨辉三角形");
//配置二维数组
for(int i=0;i<yanghui.length;i++){
yanghui[i]= new int[i+1];
}
//计算杨辉三角形
for(int n=0;n<yanghui.length;n++){
for(int k=0;k<=n;k++){
if(k==0||k==n){
yanghui[n][k]=1;
}else{
yanghui[n][k]=yanghui[n-1][k-1]+yanghui[n-1][k];
}
}
}
//输出杨辉三角形
for(int i=0;i<yanghui.length;i++){
System.out.print("第"+(i+1)+"行");
for(int j=0;j<yanghui[i].length;j++){
System.out.print(yanghui[i][j]+" ");
}
System.out.println();
}
}
}