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;
}