(C syntax FAQ 37) chicken and rabbit cage

Source: Internet
Author: User

Content: Total number of heads in the same cage, total number of feet, and how many rabbits

 

Input description:

Two integers in one row represent the total number of headers and feet respectively (ensure that there is a solution, of course, it may be solved as 0)

Output description:

One row and two integers indicate the numbers of chickens and rabbits. Example: if the question is not specified, read the data in multiple groups or refer to a001.

20 40

Output example:

20 0

 

# Include <stdio. h> int main () {int A, B, X, Y; scanf ("% d", & X, & Y); for (a = 0; A <1000; A ++) {for (B = 0; B <1000; B ++) {If (2 * A + 4 * B = Y & A + B = x) {printf ("% d \ n",, b) ;}}return 0 ;}

 

(C syntax FAQ 37) chicken and rabbit cage

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.