//作者:蒋荣军
//时间:2014.11.25
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int[,] a= new int[11, 11];
for (int i = 0; i < a.GetLength(0); i++)
{
a[i, 0] = 1;
a[i, i] = 1;
if (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 < a.GetLength(0); i++)
{
for (int j = 0; j <= i; j++)
{
Console.Write("{0,-4}", a[i, j]);
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
输出 :
总结: