番茄零乱初学C#之杨辉三角
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace PascalTriangle { class Program { static void Main(string[] args) { PT(new int[1]{1}); } static int[] PT(int[] num) { Console.Write("\n{0}", new string(' ', (10- num.Length)*2)); foreach (int j in num) { Console.Write("{0,-4}",j); } if (num.Length == 10) return num; int[] n = new int[num.Length + 1]; n[0] = n[n.Length - 1] = 1; for (int i = 1; i <=num.Length - 1; i++) { n[i] = num[i - 1] + num[i]; } return PT(n); } } }