The fifth session Waterloo Cup software category True title-c-b-1_ age coincidence

Source: Internet
Author: User
The fifth session Waterloo Cup software category True-c-b-1_ Age coincidence
* "topic"

title: Age coincidence

    Xiaoming and his cousin go to see a movie, some people ask their age. Xiao Ming said: This year is our lucky year ah.
	the four digits of my year of birth add up to just my age. Cousin's is also so. It is known that this year is 2014,
	and Xiao Ming refers to the age of years.

    please infer and fill out the year of Xiaoming's birth.

    This is a 4-bit integer, please submit the answer through the browser, do not fill in any superfluous content
	(for example, his cousin's year of birth, or their age, etc.)

* * 
Answer: 1988
* *

#include <iostream>
using namespace std;

int main ()
{
	int sum;
	int temp;
	for (int i = 2014;i>=1950;i--)
	{
		sum = 0;
		temp = i;
		while (temp)
		{
			sum = temp%10;
			Temp/=;
		if (2014-i = sum)
			cout<< "Year of birth eligible:" <<i<<endl;
	}
	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.