D017: print the number of days in a month.
Content:
Print the number of days in a month.
Input description:
Two integers in one row, followed by the year and followed by the month
Output description:
An integer
Input example:
If the questions are not described in detail, read them in multiple groups of test data, or refer to a001.
2009 6
Output example:
30
Tip: Pay attention to the definition of the leap year and the number of days in February
Source:
(Administrator: Problem)
Answer: # Include <iostream> <br/> # include <iomanip> <br/> using namespace STD; <br/> int main () <br/>{< br/> int year, month, day; <br/> CIN> year> month; <br/> If (Year % 4 = 0) & (Year % 100! = 0) | (Year % 400 = 0) <br/>{< br/> switch (month) <br/>{< br/> case 1: cout <"31" <Endl; break; <br/> case 2: cout <"29" <Endl; break; <br/> case 3: cout <"31" <Endl; break; <br/> case 4: cout <"30" <Endl; break; <br/> case 5: cout <"31" <Endl; break; <br/> case 6: cout <"30" <Endl; break; <br/> case 7: cout <"31" <Endl; break; <br/> case 8: cout <"31" <Endl; break; <br/> case 9: cout <"30" <Endl; break; <br/> case 10: cout <"31" <Endl; break; <br/> case 11: cout <"30" <Endl; break; <br/> case 12: cout <"31" <Endl; break; <br/>}< br/> else <br/> {<br/> switch (month) <br/>{< br/> case 1: cout <"31" <Endl; break; <br/> case 2: cout <"28" <Endl; break; <br/> case 3: cout <"31" <Endl; break; <br/> case 4: cout <"30" <Endl; break; <br/> case 5: cout <"31" <Endl; break; <br/> case 6: cout <"30" <Endl; break; <br/> case 7: cout <"31" <Endl; break; <br/> case 8: cout <"31" <Endl; break; <br/> case 9: cout <"30" <Endl; break; <br/> case 10: cout <"31" <Endl; break; <br/> case 11: cout <"30" <Endl; break; <br/> case 12: cout <"31" <Endl; break; <br/>}< br/> return 0; <br/>}