杨辉三角

来源:互联网 发布:大数据技能大赛试题 编辑:程序博客网 时间:2024/05/08 15:41
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication6{    class Program    {        static void Main(string[] args)        {            int[,] b= new int[12,12];            for (int i = 0; i <12 ; i++)            {                 int j = i;            for (int k = 1; k <= j; k++)            {                if (k == 1)                {                   b[j, k] = 1;                }                else if (k == j)                {                    b[j, k] = 1;                }                else                {                    b[j, k] = b[j - 1, k - 1] + b[j - 1, k];                }                Console.Write(b[j, k] + " ");                }               Console.WriteLine();                }                Console.ReadLine();         }    }}

0 0
原创粉丝点击