Question requirements:
Requirement 1: Define a struct variable (including year, month, and day ). Is the day of the current year counted? Pay attention to the leap year issue
Requirement 2: Write a function days to implement the function. The main function transfers year, month, and day to the days function. Number of days after calculation
Returns the output of the main function.
# Include <stdio. h> <br/> struct d <br/>{< br/> int year; <br/> int month; <br/> int Day; <br/> int sum; <br/>}; <br/> int days () <br/>{< br/> struct d; <br/> int I; <br/>. sum = 0; <br/> int day_of_month [12] = {31,28, 31,30, 31,30, 31,31, 30,31, 30,31}; <br/> printf ("input year, month, day, format: XXXX-XX-XX/N "); <br/> scanf (" % d-% d ", &. year, &. month, &. day); <br/> If (. year % 4 = 0 &. year % 100! = 0 |. year % 400 = 0) <br/> day_of_month [1] = 29; <br/> for (I = 0; I <. month-1; I ++) <br/>{< br/>. sum + = day_of_month [I]; <br/>}< br/>. sum + =. day; <br/> printf ("% d",. year,. month,. day); <br/> return. SUM; <br/>}< br/> void main () <br/> {<br/> printf ("% d day/N of the Year ", days (); <br/>}