用JAVA打印:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
..........................
............................
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
..........................
............................
import java.util.LinkedList;
import java.util.List;
public class Test2 {
public static void main(String[] args) {
List<Integer> current = new LinkedList<Integer>();
current.add(1);
for (int i = 0; i < 6; i++) {
System.out.println(current);
current = getList(current);
}
}
public static List<Integer> getList(List<Integer> list) {
List<Integer> result = new LinkedList<Integer>();
if (list.size() == 1) {
result.add(1);
result.add(1);
return result;
}
for (int i = 0; i < list.size() + 1; i++) {
if (i == 0 || i == list.size()) {
result.add(1);
continue;
}
result.add(list.get(i) + list.get(i - 1));
}
return result;
}
}