zoukankan      html  css  js  c++  java
  • 杨辉三角简单示例

     static void Main(string[] args)
            {
                /*
                 *
                 *  1
                 *  1  1
                 *  1  2  1
                 *  1  3  3  1
                 *  1  4  6  4  1
                 *  1  5  10 10  5  1
                 */          
                int[,]arry=new int[6,6];
                for (int i = 0; i < 6; i++)
                {
                    arry[i, 0] = 1;
                    arry[i, i] = 1;
                    for (int j = 1; j < i+1; j++)
                    {
                     arry[i,j]=arry[i-1,j-1]+arry[i-1,j];                 
                    }
                }
                for(int i=0;i<6;i++)
                {
                    for(int j=0;j<=i;j++)
                    {
                        Console.Write(arry[i,j]+" ");
                    }
                    Console.WriteLine();
                }


            }

    运行结果:

  • 相关阅读:
    leetcode : Valid Sudoku
    leetcode : Longest Increasing Subsequence
    leetcode : Search for a Range
    leetcode : Search Insert Position
    leetcode : next permutation
    leetcode : Implement strStr()
    leetcode : Remove Element
    框架:Spring MVC
    笔试:在线编程相关
    J2EE:关系(一对多、多对一、多对多关系)
  • 原文地址:https://www.cnblogs.com/lsysunbow/p/2369972.html
Copyright © 2011-2022 走看看