李敏  
日历
<2026年9月>
日一二三四五六
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
统计
  • 随笔 - 1
  • 文章 - 40
  • 评论 - 4
  • 引用 - 0

导航

常用链接

留言簿(1)

文章分类

文章档案

相册

收藏夹

它山之石

聚贤庄

搜索

  •  

最新评论

 
     1

     1     1

     1     2     1

     1     3     3     1

     1     4     6     4     1

     1     5    10    10     5     1 


   
int[] lastNums = { 1 };
        
int[] nextNums;

        
int len = 5;

        
for (int i = 2; i <= len; i++) {
            nextNums 
= new int[i];

            
for (int j = 1; j < i - 1; j++) {
                nextNums[j] 
= lastNums[j - 1] + lastNums[j];
            }


            nextNums[
0] = lastNums[0];
            nextNums[i 
- 1] = lastNums[i - 2];

            lastNums 
= nextNums;
        }
posted on 2009-09-20 12:36 李敏 阅读(318) 评论(0)  编辑  收藏 所属分类: 算法
 
Copyright © 李敏 Powered by: 博客园 模板提供:沪江博客