zoukankan      html  css  js  c++  java
  • 流氓兔循环一练

     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();
                }

            }
        }
    }

  • 相关阅读:
    hd2068错排+组合
    POJ 1061 青蛙的约会 扩展欧几里得
    POJ 2115 C Looooops扩展欧几里得
    扩展欧几里得算法
    欧拉函数模板
    高精度模板
    快速幂模板
    HDU 4445 Crazy Tank 高中物理知识忘得差不多了
    POJ 3087 Shuffle'm Up 模拟,看着不像搜索啊
    HDU 4452 Running Rabbits 模拟
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4381755.html
Copyright © 2011-2022 走看看