Home > Back-end >  Wow, bosses, always show the answer wrong
Wow, bosses, always show the answer wrong

Time:05-04

Output in the 21st century as a year since the year of all the leap year, note: determining the criterion of a leap year is the year can be divided exactly by 4 years but cannot be divided exactly by 100, or divisible by 400,

Input format:
Input in a row in a year as of the 21st century,

The output format:
Line by line output meet the conditions of all leap year years, each year a line, input output without years of the 21st century is "Invalid year!" , if there are no leap year, then output "None",

Input the sample 1:
2048
The output sample 1:
2004
2008
2012
2016
2020
2024
2028
2032
2036
2040
2044
2048
Enter the sample 2:
2000
The output sample 2:
Invalid year!






#include
Int main ()
{int I, n, flag=0;
The scanf (" % d ", & amp; N);
If (n> 2100 | | n
=2000)Printf (" Invalid year! \n");
The else {for (I=2001; I<=n; I++)
{if (I % 4 & amp; & I % 100!=0 | | I %==0 400)
{flag=1;
Printf (" % d \ n ", I); }}
If (flag==0)
Printf (" None \ n "); }
return 0;



?

}

?

CodePudding user response:

Reference:
 # include 
Int main ()
{
Int I, n, flag=0;
The scanf (" % d ", & amp; N);
If (n> 2100 | | n
=2000)Printf (" Invalid year! \n");
The else {
For (I=2001; I<=n; I++)
{
If ((I % 4==0 & amp; & I % 100!=0) | | (I % 400==0))
//if (I % 4 & amp; & I % 100!=0 | | I %==0 400)
{
flag=1;
Printf (" % d \ n ", I);
}
}
If (flag==0)
Printf (" None \ n ");
}

return 0;
}