Program Design guidance and online practice Reading Notes 2.1-chicken and rabbit cage

Source: Internet
Author: User

Http://blog.csdn.net/pipisorry/article/details/36433305

Problem description
The chicken and rabbit are closed in a cage (the chicken has two feet and the rabbit has four feet, no exception ). I already know the total number of feet in the cage. I asked how many animals are in the cage and how many animals are there at most.

Input
The first row is the number of N groups of test data, followed by N rows of input. Each group of test data occupies one row and each row has a positive integer a (A <32768)

Output
The output contains N rows. Each row corresponds to one input and contains two positive integers. The first is the minimum number of animals, and the second is the maximum number of animals. The two positive integers are separated by a space.
If no answer meets the requirements, two zeros are output.

Sample Input
2
3
20
Sample output
0 0
5 10
========================================================== ========================================================== =====

/*************************************** *************************************//* Poj Reading Notes 2.1 -- chicken and rabbit skins in the same cage *//************************** **************************************** * *********/# include <stdio. h> void cage () {int count; scanf ("% d", & COUNT); int A; while (count --) {scanf ("% d ", & A); if (a % 2) {// the odd number does not parse printf ("0 0 \ n");} else {printf ("% d \ n ", a/4 + A % 4/2, a/2); // minimum a/4 (the remaining a % 4/2 are chicken); Maximum A/2 (no rabbit )}}} void main () {cage ();}



From: http://blog.csdn.net/pipisorry/article/details/36433305


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.