流氓兔循环一练
static void Main(string[] args)
{
while (true)
{
int ct=0,xt=0,yt=1,zt=1,m;
Console.WriteLine("请输入月数:");
m = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= m; i++)
{
if (i == 1)
{
yt = 1;
Console.WriteLine(i + "月的幼兔数为" + yt);
xt = 0;
Console.WriteLine(i + "月的幼兔数为" + xt);
ct = 0;
Console.WriteLine(i + "月的幼兔数为" + ct);
zt = 1;
Console.WriteLine(i + "月的幼兔数为" + zt);
Console.WriteLine("");
}
else //下面这些公式有一些不懂得
{
ct = xt + ct;
Console.WriteLine(i + "月这个月的成兔为" + ct);
xt = yt;
Console.WriteLine(i + "月这个月的小兔为" + xt);
yt = ct;
Console.WriteLine(i + "月这个月的幼兔为" + yt);
zt = yt + xt + ct;
Console.WriteLine(i + "月这个月的总兔为" + zt);
Console.WriteLine("");
}
Thread.Sleep(500);
}
Console.ReadLine();
}
}
}
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步