This question does not include the correct date judgment function # include <stdio. h>
Struct date
{
Int year;
Int month;
Int Day;
};
Int leap_year (int );
Int cal_day (struct date );
/* Determine a leap year */
Int leap_year (int)
{
If (a % 400 = 0 | (a % 4 = 0 & A % 100! = 0 ))
Return 1;
Else
Return 0;
// If (a % 400 = 0)
// Return 1;
// Else if (a % 100 = 0)
// Return 0;
// Else if (a % 4 = 0)
// Return 1;
// Else
// Return 0;
}
/* Calculate the day of the year */
Int cal_day (struct date)
{
Int sum = 0, B [] = {31,28, 31,30, 31,30, 31,31, 30,31, 30,31 };
For (INT I = 0; I <A. Month-1; I ++)
Sum + = B [I];
If (A. Month> 2)
Sum = sum + A. day + leap_year (A. year );
Else
Sum = sum + A. Day;
Return sum;
}
Void main ()
{
Struct date;
Int N;
Printf ("\ n enter the date (year month day) \ n ");
Scanf ("% d", & A. Year, & A. Month, & A. Day );
N = cal_day ();
Printf ("this day in this year is % d day \ n", N );
}