package leetcode; import java.util.ArrayList; import java.util.List; public class demo_119 { public List<Integer> getRow(int rowIndex) { List<Integer> list=new ArrayList<Integer>(); list.add(1); //每一行都是(a+b)的n次方的系数,下一个系数第(i+1)项的系数等于第i项的系数乘以(n-i)/(i+1) for(int i=0;i<rowIndex;i++) { long num=(long)list.get(i)*(rowIndex-i)/(i+1); list.add((int)num); } System.out.println(list); return list; } public static void main(String[] args) { // TODO Auto-generated method stub demo_119 d119 =new demo_119(); d119.getRow(30); } }