如何在C#中构建窗体类应用程序,实现计算斐波那契数列的第n项。。。。。。。。。。。。。。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Q1086908
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private int f(int n)
{
if (n == 1 || n == 2) return 1;
return f(n - 2) + f(n - 1);
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = f(int.Parse(textBox1.Text)).ToString();
}
}
}