using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); if (n <= 0) { Console.WriteLine("必须大于0"); return; } if (n == 1) //时刻注意边界值!!! { Console.WriteLine("1"); return; } int[] data = new int[n]; data[0] = 1; data[1] = 1; for (int i = 2; i < n; i++) { data[i] = data[i - 1] + data[i - 2]; } Console.WriteLine(data[n - 1]); Console.ReadLine(); } } }