//求下列数列的前20项 // * 0 n=0 // * 1 n=1 //y[n]=* 2 n=2 // * y[n-1]+2*y[n-2]+y[n-3] n>2 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace test { class Program { static void Main() { int[] y = new int[20]; //C#中的动态分配 y[0] = 0; y[1] = 1; y[2] = 2; for (int i = 3; i <20; i++) { y[i] = y[i - 1] + 2 * y[i - 2] + y[i - 3]; } foreach (int i in y) { Console.WriteLine(i); } } } }