如何在C#中构建窗体类应用程序,实现计算斐波那契数列的第n项。。。。。。。。。。。。。。
1条回答 默认 最新
- threenewbee 2020-06-22 21:58关注
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(); } } }
问题解决的话,请点下采纳
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报