C Language-mice

Source: Internet
Author: User

/* Suppose a pair of rats can have a pair of mice each month. After 3 months of growth, the mouse will be able to give birth to a small mouse from the 4th month onwards.

Q: If all the rats are not dead, then how many rats are there in 20 months? */

#include <stdio.h>

void Main ()

{

int old = 2,first = 0,second = 0,third = 0;

int i= 0;

for (; i < 20;i++)

{

Old = old + third;

Third = second;

second = first; first = old;

}

printf ("The 20th month there are altogether%d rats!") \ n ", old + first + second + third);

}

/* Experience: This topic belongs to Business Modeling:

0月 January February March April May June ...

Old 2 2 2 2 4 6 8

January 0 2 2 2 4 6 8

February 0 0 2 2 2 4 6

March 0 0 0 2 2 2 4

Total 2 4 6 8 12 18 26

*/

C Language-mice

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.