For Loop statement the Rabbit cub

Source: Internet
Author: User

There are a pair of young rabbits, the young rabbit after one months long as a small rabbit, the rabbit after one months long as a big rabbit and gave birth to a pair of young rabbits, and the big Rabbit will give birth to a pair of young rabbits a month, ask N months after how many pairs of rabbits

Console.WriteLine ("Please enter after a few months:"); intn =Convert.ToInt32 (Console.ReadLine ()); intSYT =1, byt =0; intSXT =0, BXT =0; intSDT =0, BDT =0;  for(inti =1; I <= N; i++) {byt= SDT +SXT; BXT=SYT; BDT= SDT +SXT; SYT=byt; SXT=Bxt; SDT=BDT; } Console.WriteLine ("after"+ N +"months later:"); Console.WriteLine ("The young rabbits are:"+ Byt +"the"); Console.WriteLine ("Bunny for:"+ BXT +"the"); Console.WriteLine ("The Big rabbit is:"+ BDT +"the"); intsum = byt + BXT +BDT; Console.WriteLine ("The rabbits are:"+ Sum +"the"); Console.WriteLine ("There are altogether: {0} pairs, the rabbit has {1} pairs", sum, BXT);

For Loop statement the Rabbit cub

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.