C-Language Classic topic-Rabbit born Rabbit

Source: Internet
Author: User

By this month into a rabbit = last month into a rabbit + month rabbit; this month bunny = last month cub; this month's Bunny = Rabbit this month

Using the While loop:

Console.WriteLine ("Please enter the month:");
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 ("First" + M + "months into the rabbit logarithm is:" + ct);
Console.WriteLine ("The first" + M + "months of the small rabbit logarithm is:" + XT);
Console.WriteLine ("s" + M + "months of the young rabbit logarithm is:" + YT);
Console.WriteLine ("The first" + M + "months of the total rabbit logarithm is:" + ZT);

Take advantage of A For loop:

Console.WriteLine ("Please enter the month:");
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 ("First" + M + "months into the rabbit logarithm is:" + ct);
Console.WriteLine ("The first" + M + "months of the small rabbit logarithm is:" + XT);
Console.WriteLine ("s" + M + "months of the young rabbit logarithm is:" + YT);
Console.WriteLine ("The first" + M + "months of the total rabbit logarithm is:" + ZT);

C-Language Classic topic-Rabbit born Rabbit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.