怎么用打印出杨辉三角形啊 怎么打印出如下杨辉三角形? 1 1 2 1 1 3 3 11 4 6 4 1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://wzcsying.blog.51cto.com/284684/53767/ http://blog.csdn.net/linux7985/article/details/5987155多个方法实现杨辉三角形 http://wzcsying.blog.51cto.com/284684/53767/http://wzcsying.blog.51cto.com/284684/53767/ http://topic.csdn.net/u/20090530/17/393a6b38-10dd-4031-9093-03f7c8130072.html 我的面试题也差不多是用两个for循环做出来,---*----*-*-*-*-*-*-*-*-*-*----*---求大侠们指点下 using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ static class Helper { //m!/(n!*(m-n)!) public static int C(int m, int n) { return facEx(n + 1, m) / facEx(2, m - n); } private static int facEx(int from, int to) { int result = 1; for (int i = from; i <= to; i++) { result *= i; } return result; } } class Program { static void Main(string[] args) { int n = 8; int[][] result = new int[n + 1][]; for (int i = 0; i < n + 1; i++) { result[i] = new int[i + 1]; for (int j = 0; j <= i; j++) { result[i][j] = Helper.C(i, j); } } foreach (int[] item in result) { Console.WriteLine(string.Join(" ", item.Select(x => x.ToString().PadLeft(3, ' ')).ToArray())); } } }} 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 1 8 28 56 70 56 28 8 1Press any key to continue . . . 自定义控件如何在程序退出时自动执行一个方法? C#调用cmd.exe窗体不显示内容的问题。 多线程无法正常使用VedioCapture类 关于C#中怎样才能实现向DataGridView中填充表的记录?用代码写。。。。。 c#中画图的问题! 如何比较时间的先后 需要这样一个控件! WPF,请问Expression Blend工具的用途 安装IEWebControls.msi后,怎样在工具箱中找到它? 这句话那里错了?document.all(Button1).click(); C# windows控件重叠问题 设置断点调试问题
---*---
-*-*-*-
*-*-*-*
-*-*-*-
---*---
求大侠们指点下
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
static class Helper
{
//m!/(n!*(m-n)!)
public static int C(int m, int n)
{
return facEx(n + 1, m) / facEx(2, m - n);
} private static int facEx(int from, int to)
{
int result = 1;
for (int i = from; i <= to; i++)
{
result *= i;
}
return result;
}
} class Program
{
static void Main(string[] args)
{
int n = 8;
int[][] result = new int[n + 1][];
for (int i = 0; i < n + 1; i++)
{
result[i] = new int[i + 1];
for (int j = 0; j <= i; j++)
{
result[i][j] = Helper.C(i, j);
}
}
foreach (int[] item in result)
{
Console.WriteLine(string.Join(" ", item.Select(x => x.ToString().PadLeft(3, ' ')).ToArray()));
}
}
}
} 1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
Press any key to continue . . .