(hundred cases programming) 77. Possonval of wine

Source: Internet
Author: User

Title: The famous French mathematician, Virgin, studied an interesting mathematical problem in the time of the year: someone had a bottle of 12 pints of beer and wanted to pour 6 pints out of it, but he didn't have 6 pints of container, only 8 pints and 5 pints of containers, how to divide the beer into two pints.


/* Title: Virgin, a famous French mathematician, studied an interesting mathematical problem in the time of the year
: someone had a bottle of 12 pints of beer to
pour out 6 pints, but he did not have 6 pints of container, only a 8 pint
and 5 pint container, How to divide a beer into two 6 pints. by
as1138 2012-08-13
*/

#include <iostream>
using namespace std;

int main (int argc, char const *argv[])
{
    int nTw = n;
    int nEi = 0;
    int nFi = 0;
	while (true)
	{
		if (nEi = = 0)//8 capacity bottle is empty
		{
			nTw-= 8;
			NEi + = 8;
		}
		else if (nFi = = 5)//5 capacity bottle is full
		{
            nTw + = 5;
            nFi = 0;
		}
		else if (NFi < 5)//5 capacity bottle is not full
		{
			int nT = 5-NFI;
			if (NT > NEi)
			{
				nFi + = nEi;
				nEi = 0;			
			}
			else
			{
				NEi-= NT;
				NFi + = NT;
			}
		}
		cout<<ntw<< "" <<nEi<< "" <<nFi<<endl;
		if (nTw = = 6&&nei = = 6) break
		    ;
		cout<< "  ↓" <<endl;
	} End
	while return 0;
}


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.