const int length = 8; var a = new int[length][]; for (var i = 0; i < a.Length; i++) { a[i] = new int[i + 1]; } for (var j = 0; j < a.Length; j++) { a[j][0] = 1; a[j][j] = 1; for (var m = 1; m < a[j].Length - 1; m++) { a[j][m] = a[j - 1][m - 1] + a[j - 1][m]; } } foreach (var t in a) { foreach (var t1 in t) { Console.Write("{0}\t",t1); } Console.Write("\n"); } Console.Read();
时间: 2024-11-07 05:41:37