Copyright (c) 2014软件技术1班
03.// All rights reserved.
04.// 作 者:A20
05.// 完成日期:2014年 11 月 23日
06.// 版 本 号:v1.0
07.// 下面是描述杨辉三角程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{int[,]a=new int[11,11];
for (int i = 0; i < a.GetLength(0); i++)
{
for (int j = 0; j <a.GetLength(1); j++)
{
a[i, 0] = 1;
if (i == j) a[i, j] = 1;
else if (i>=2&&j>=1) 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 < a.GetLength(1); j++)
Console.Write("{0}\t", a[i, j]);
Console.Write("\n");
}
Console.Read();
}
}
}
<img src="https://img-blog.csdn.net/20141123132519778?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQva2s1NTM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
总结:在写这个程序时前面很好写,但是算i>=2那一步老是算不出来最后乱稿一通终于写出来了