// Copyright (c) 2014软件技术1班
// All rights reserved.
// 作 者:A35卢杰林
// 完成日期:2014年 11 月 22 日
// 版 本 号:v1.0
//
// 问题描述:杨辉三角
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace yanghuisanjiaoxing
{
class Program
{
static void Main(string[] args)
{
int[,]number=new int[11,11];
for (int i = 0; i < 11; i++)
{
number[i,0]=1;
number[i,i]=1;
}
for (int i = 2; i< 11; i++)
for (int j = 1; j < 11;j++)
{
number[i,j]=number[i-1,j-1]+number[i-1,j];
}
for (int i = 0;i < 11; i++)
{
Console.Write(" \n ");
for (int j = 0;j <=i;j++)
{
Console.Write(" {0} ",number[i,j]);
}
}
Console.ReadKey();
}
}
}
<img src="https://img-blog.csdn.net/20141126154904640" alt="" />
杨辉三角形
最新推荐文章于 2024-03-17 18:00:07 发布