import java.util.Scanner;
public class 类名 {
//打印杨辉三角
public static void main(String[] args) {
f();
}
public static void f(){
System.out.println(“请输入要求打印的行数:”);
Scanner sca = new Scanner(System.in);
int lines = sca.nextInt();//从控制台输入行数
int[] a = new int[lines+1];//
int previous = 1;//原先的值
for (int i = 1; i <= lines; i ++){//第几行
for (int j = 1; j <= i; j++){//每行的数字的个数,第几行就有几个数
int current = a[j];//目前的值为a[j],从a数组的下标为1的位置输出
a[j] = previous + current;
previous = current;
System.out.print(a[j] + ” “);
}
System.out.println();//输完一行后换行
}
}
}