C#之二维数组学习案例

来源:互联网 发布:淘宝上的国大药房 编辑:程序博客网 时间:2024/04/28 11:34
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace YHtriangle{    class Program    {        static void Main()        {            int[,] a = new int[6, 6];            a[0, 0] = 1;            for (int i = 1; i <= 5; i++)            {                a[i, 0] = 1;                a[i, i] = 1;                for (int j = 1; j <= i; j++)                {                    a[i, j] = a[i - 1, j - 1] + a[i - 1, j];                }            }            for (int i = 0; i <= 5; i++)            {                for (int j = 0; j <= i; j++)                {                    Console.Write("{0}\0", a[i, j]);                }                Console.WriteLine();            }        }    }}

0 0
原创粉丝点击