杨辉三角
2017-01-20 16:05
253 查看
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(); } } }
相关文章推荐
- 杨辉三角c++实现
- uva10883 - Supermean 杨辉三角
- HDU 2032 杨辉三角
- hdu2032 杨辉三角
- NYOJ-杨辉三角
- UVa 10883 - Supermean (杨辉三角 通过取对数解决大数除大数)
- POJ 3187 Backward Digit Sums (杨辉三角,穷竭搜索,组合数,DFS)
- 输出杨辉三角前10行
- 杨辉三角的形状
- 上机作业 杨辉三角
- 杨辉三角
- 杨辉三角集锦
- 杨辉三角
- HDU2032 杨辉三角
- (1.1.8)循环算法的特征以及典型循环算法杨辉三角、螺旋队列等
- 输出杨辉三角(C++和 JAVA版 )
- P123 第30题 求杨辉三角的第39行第19列的数
- C语言,输出杨辉三角
- hdoj 3664 Permutation Counting 【递推 有点类似杨辉三角】
- 杨辉三角