01.Copyright (c) 2014软件技术1班
02.// All rights reserved.
03.// 作 者:A14张森程
04.// 完成日期:2014年 11 月 23日
05.// 版 本 号:v1.0
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 杨辉三角_
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[11, 11];
string s = "";
string space=" ";
for (int i = 0; i < a.GetLength(0); i++)
{
for (int j = 0; j <=i; j++)
{
if (j == 0 ||j==i) a[i, j] = 1;
else a[i, j] = a[i - 1, j - 1] + a[i - 1, j];
}
}
for (int i = 0; i < a.GetLength(0); i++)
{
Console.WriteLine();
s="";
space=space.Substring(2);
s=s+space;
for (int j = 0; j <= i; j++)
{
s = s + a[i, j].ToString() + " ";
}
Console.WriteLine(s);
}
Console.ReadKey();
}
}
}
<img src="https://img-blog.csdn.net/20141123222656476?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2VuY2hlbmc2MTE5/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
总结:我学会了编程杨辉三角,太高兴了