杨辉三角形

来源:互联网 发布:java 异步写文件 编辑:程序博客网 时间:2024/05/16 01:09

  1. 2014软件技术1班
  2. 作    者:A19秦嘉琪   
  3.  完成日期:2014年 11 月 23日  
  4.  问题描述:杨辉三角形
  5. 输入描述:
  6. 程序输出:






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();




        }
    }

}




总结:进一步了解二维数组。

0 0