Multi-solution of chicken-Rabbit cage problem

Source: Internet
Author: User

Remember that there was a run of men there is a chicken and rabbit cage problem, said the chicken rabbit cage, a total of 35 head, 94 legs, asked how many chickens? How many rabbits?

Today's whim to use the recent Java knowledge to do this problem, of course, the result of the problem I was written calculation out, in order to verify the correctness of the output, not to say, directly on the code:

In fact, from the order of view will find that the code is more and more simple, and finally even give up the use of the loop to complete, completely into a mathematical formula, but at that time, I had just done, I fully merely two hours to clear the train of thought, then a few more easily made out.

Thinking is very important, want to self-accomplish a thing must have clear ideas, this is just a very simple topic, but let me learn a lot.

Multi-solution of chicken-Rabbit cage problem

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.