程序流程不繁杂,立即上编码了:

    class Program
    {
        static void Main(string[] args)
        {
            int length = 0;//杨辉三角形的长短 
            Console.Write("键入杨辉三角长短:");
            length = Convert.ToInt32(Console.ReadLine());//特定杨辉三角形的长短
            int[][] a = new int[length][];//二维数组
            for (int i = 0; i < a.Length; i  )
                a[i] = new int[i   1];//解析xml,取值增加量
            for (int j = 0; j < a.Length; j  )
            {
                a[j][0] = 1; //把第一列的原素都赋1
                a[j][j] = 1; //把每1列最右侧的原素都赋1
                for (int m = 1; m < a[j].Length - 1; m  )
                    a[j][m] = a[j - 1][m - 1]   a[j - 1][m];//其他原素的值由杨辉计算公式
            }
            for (int i = 0; i < a.Length; i  ) //遍历数组輸出杨辉三角形
            {
                for (int k = 0; k < length -i;k  )
                    Console.Write(" ");
                for (int j = 0; j < a[i].Length; j  )
                    Console.Write("{0} ", a[i][j]);
                Console.Write("\n");
            }
            Console.Read();
        }
    }

运作实际效果以下: