码迷,mamicode.com
首页 > 其他好文 > 详细

Exercise 1.11---1.12 Pascal's Triangle

时间:2014-09-15 17:25:09      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:ar   strong   sp   on   c   line   r   bs   as   

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

标签:ar   strong   sp   on   c   line   r   bs   as   

原文地址:http://www.cnblogs.com/linghuaichong/p/3973152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!