20141016 -- for Rabbit

Source: Internet
Author: User
1 Console. write ("Enter the number of months:"); 2 int M = int. parse (console. readline (); 3 int Ct = 0; // rabbit logarithm CT 4 int XT = 0; // rabbit logarithm XT 5 Int yt = 1; // rabbit logarithm yt 6 int zt = 1; // total rabbit logarithm ZT 7 for (INT I = 1; I <= m; I ++) 8 {9 if (I = 1) // defines the number of rabbits in the first month as 10 {// (tell the computer the number of rabbits in the first month) 11 Ct = 0; // rabbit logarithm = 012 XT = 0 in the first month; // rabbit logarithm = 013 yt = 1 in the first month; // number of young rabbits in the first month = 114} 15 else16 {17 Ct = XT + CT; // The number of rabbits in each month equals to the number of rabbits in the previous month + the number of rabbits in the previous month 18 XT = yt; // The number of rabbits in each month is equal to the number of rabbits in the previous month, 19 yt = CT; // The number of rabbits in each month is equal to the number of rabbits in this month. 20} 21 zt = CT + XT + yt; // The total number of Rabbits is equal to 22 for rabbits and rabbits. writeline (I. tostring () + "the rabbit's logarithm after the month is:" + CT. tostring (); 23 console. writeline (I. tostring () + "the rabbit's logarithm after the month is:" + XT. tostring (); 24 console. writeline (I. tostring () + "the logarithm of the young rabbit after the month is:" + yt. tostring (); 25 console. writeline (I. tostring () + "the total rabbit logarithm after the month is:" + ZT. tostring (); 26 console. readline (); 27} 28 console. readline ();

 

There are 3 rabbits, 2 rabbits, 5 rabbits, 3 months after the rabbit grew into a rabbit, the rabbit grew into a rabbit, each rabbit gave birth to a young rabbit,

1 Console. write ("Enter the number of months"); 2 int M = int. parse (console. readline (); 3 int Ct = 3; // rabbit logarithm CT 4 int XT = 2; // rabbit logarithm XT 5 Int yt = 5; // rabbit logarithm yt 6 int zt = 0; // total rabbit logarithm ZT 7 for (INT I = 1; I <= m; I = I + 3) 8 {9 if (I = 1) 10 {11 Ct = 3; // the first month of the rabbit's logarithm 12 XT = 2; // for rabbits in the first month, 13 yt = 5; // for rabbits in the first month, 14 zt = CT + yt + XT; // The total number of rabbits in the first month is 15} 16 else17 {18 Ct = CT + XT; // The number of rabbits in the current month = the number of rabbits in the previous month + the number of rabbits in the previous month 19 XT = yt; // The number of rabbits in this month = the number of rabbits in the previous month 20 yt = CT; // The number of rabbits in this month = the number of rabbits in this month 21} 22 zt = CT + XT + yt; // The total number of Rabbits is equal to the number of rabbits plus rabbits 23 console. writeline ("th" + (I ). tostring () + "when the rabbit logarithm is:" + CT. tostring (); 24 console. writeline ("th" + (I ). tostring () + "when the rabbit's logarithm is:" + XT. tostring (); 25 console. writeline ("th" + (I ). tostring () + "when the number of months is:" + yt. tostring (); 26 console. writeline ("th" + (I ). tostring () + "when the rabbit's total logarithm is:" + ZT. tostring (); 27 console. readline (); 28} 29

 

20141016 -- for Rabbit

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.