Source:
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1201
Description:
Enter the date of birth to calculate the number of days after the 18-year-old birthday
Solution:
Problem solving source code
# Include <stdio. h> </P> <p> int isleapyear (INT nyear) <br/>{< br/> If (nyear % 4 = 0 & nyear % 100! = 0) | nyear % 400 = 0) <br/> return 1; <br/> else <br/> return 0; <br/>}</P> <p> int main () <br/> {<br/> int y, M, D, T, J, date; <br/> scanf ("% d", & T); <br/> while (t --) <br/>{< br/> date = 18*365; <br/> scanf ("% d-% d", & Y, & M, & D); <br/> If (! Isleapyear (Y + 18) & (M = 2 & D = 29) <br/>{< br/> printf ("-1/N "); <br/>}< br/> else <br/> {<br/> If (isleapyear (y) & (M <2 | (M = 2 & D <= 28) <br/> date ++; <br/> If (isleapyear (Y + 18) & (M> 2 | (M = 2 & D = 29 ))) <br/> date ++; <br/> for (j = Y + 1; j <= Y + 17; J ++) <br/>{< br/> date + = isleapyear (j); <br/>}< br/> printf ("% d/N", date ); <br/>}< br/> return 0; <br/>}