博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杨辉三角
阅读量:4097 次
发布时间:2019-05-25

本文共 1519 字,大约阅读时间需要 5 分钟。

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {            int [][] Array_int = new int[10][];            //遍历行数            for (int i = 0; i < Array_int.Length; i++ )            {                //定义二维数组的列数                Array_int[i] = new int[i+1];                //遍历列数                for (int j = 0; j < Array_int[i].Length;j++ )                {                    //数组的前两行                    if(i <= 1)                    {                        Array_int[i][j] = 1;                        continue;                    }                    else                    {                        //行首或行尾                        if(j == 0 || j == Array_int[i].Length - 1)                        {                            Array_int[i][j] = 1;                            continue;                        }                        else                        {                            Array_int[i][j] = Array_int[i-1][j-1] + Array_int[i - 1][j];                        }                    }                }            }            //打印            for (int i = 0; i < Array_int.Length; i++)            {                for (int j = 0; j < Array_int[i].Length; j++)                {                    Console.Write("{0}\t", Array_int[i][j]);                }                Console.WriteLine();            }            Console.ReadLine();        }    }}

转载地址:http://dteii.baihongyu.com/

你可能感兴趣的文章
【机器学习】机器学习系统SysML 阅读表
查看>>
最小费用流 Bellman-Ford与Dijkstra 模板
查看>>
zookeeper(3)---zookeeper API的简单使用(增删改查操作)
查看>>
zookeeper(4)---监听器Watcher
查看>>
mapReduce(3)---入门示例WordCount
查看>>
hbase(3)---shell操作
查看>>
hbase(1)---概述
查看>>
hbase(5)---API示例
查看>>
SSM-CRUD(1)---环境搭建
查看>>
SSM-CRUD(2)---查询
查看>>
SSM-CRUD (3)---查询功能改造
查看>>
Nginx(2)---安装与启动
查看>>
springBoot(5)---整合servlet、Filter、Listener
查看>>
C++ 模板类型参数
查看>>
C++ 非类型模版参数
查看>>
DirectX11 光照
查看>>
图形学 图形渲染管线
查看>>
DirectX11 计时和动画
查看>>
DirectX11 光照与材质的相互作用
查看>>
DirectX11 环境光
查看>>