首页 > 代码库 > Exercise 1.11---1.12 Pascal's Triangle
Exercise 1.11---1.12 Pascal's Triangle
1.11 F‘ibonates函数的变种,略过。
1.12 题目:
The following pattern of numbers is called Pascal‘s triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
......
The numbers at the edge of the triangle are all 1, and each number inside the triangle is the sum of the two numbers above it.35 Write a procedure that computes elements of Pascal‘s triangle by means of a recursive process.
只要按照如下公式计算即可:
number_at(row, line)
number_at(1,N)=1
number_at(N,N)=1
number_at(N,M)=number_at(N-1,M-1)+number_at(N-1,M)
Exercise 1.11---1.12 Pascal's Triangle
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。