zoukankan      html  css  js  c++  java
  • C#部分---语言经典题目——兔子生兔子

    根据本月成兔=上月成兔+上月小兔;本月小兔=上月幼兔;本月幼兔=本月成兔

    利用while循环:

    Console.WriteLine("请输入月份:");
    //int m = int.Parse(Console.ReadLine());
    //int ct = 0;
    //int xt = 0;
    //int yt = 1;
    //int zt = 1;
    //int i = 1;
    //while(i<=m)
    //{
    // if (i == 1)
    // {
    // ct = 0;
    // xt = 0;
    // yt = 1;
    // }
    // else
    // {
    // ct = ct + xt;
    // xt = yt;
    // yt = ct;
    // }

    // zt = ct + xt + yt;
    // i++;
    //}

    //Console.WriteLine("第" + m + "个月的成兔对数是:" + ct);
    //Console.WriteLine("第" + m + "个月的小兔对数是:" + xt);
    //Console.WriteLine("第" + m + "个月的幼兔对数是:" + yt);
    //Console.WriteLine("第" + m + "个月的成总兔对数是:" + zt);

    利用for循环:

    // Console.WriteLine("请输入月份:");
    // int m=int.Parse(Console.ReadLine());
    // int ct = 0;
    // int xt = 0;
    // int yt = 1;
    // int zt=1;
    // for (int i = 1; i <= m;i++ )
    // {
    // if (i == 1)
    // {
    // ct = 0;
    // xt = 0;
    // yt = 1;

    // }
    // else
    // {
    // ct = ct + xt;
    // xt = yt;
    // yt = ct;


    // }
    // zt = ct + xt + yt;
    //}
    //Console.WriteLine("第" + m + "个月的成兔对数是:" + ct);
    //Console.WriteLine("第" + m + "个月的小兔对数是:" + xt);
    //Console.WriteLine("第" + m + "个月的幼兔对数是:" + yt);
    //Console.WriteLine("第" + m + "个月的成总兔对数是:" + zt);

  • 相关阅读:
    oracle 第12章 归档日志文件
    oracle 第09章 参数文件
    oracle 第11章 重做日志文件
    oracle 第10章 控制文件
    oracle 第14章 表空间管理
    linux yum源配置
    oracle 第08章 用户、权限、角色管理
    oracle 第07章 网络配置管理
    第二阶段冲刺-06
    第二阶段冲刺-05
  • 原文地址:https://www.cnblogs.com/xingyue1988/p/5947410.html
Copyright © 2011-2022 走看看