-----------------------------------------------------------
-----------------------------------------------------------
算法
1 import java.util.*; 2 public class Main { 3 public static void main(String[] args) { 4 int n = new Scanner(System.in).nextInt(); 5 int[] a = null; 6 System.out.println(1); 7 for(int i=2;i<=n;i++){ 8 int[] s = new int[i]; 9 s[0] =s[i-1] = 1; 10 System.out.print("1 "); 11 for(int j=1;j<=i-2;j++){ 12 s[j] = a[j-1]+a[j]; 13 System.out.print(s[j]+" "); 14 } 15 System.out.println("1"); 16 a = s; 17 } 18 } 19 }
时间: 2024-11-05 15:48:52