/*************************************** ************************
C Language
AUTHOR: liuyongshui
**************************************** ***********************/
/*
Question 14: define a struct variable (including year, month, and day). Enter the year, month, and day to calculate and output the day of the year.
*/
# Include <stdio. h>
Struct date
{
Int year;
Int month;
Int day;
};
Int checkyear (int n); // statement of the original function, used to check whether it is a leap year or a flat year. If it is 'distinct', 1 is returned; otherwise, 0 is returned.
Const int Day_Of_Month [] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31 }; // The number of days of each month on a yearly basis
Int main ()
{
Int I;
Int flag;
Int sum_day = 0;
Struct date birthday;
Printf ("Enter your date of birth :");
Scanf ("% d", & birthday. year, & birthday. month, & birthday. day );
Flag = checkyear (birthday. year );
If (flag) // if the flag is distinct, 1 is returned, and 0 is returned.
{
Sum_day ++;
}
For (I = 0; I <birthday. month; I ++)
{
Sum_day + = Day_Of_Month [I];
}
Sum_day + = birthday. day;
Printf ("after scientific computation, you were born on day % d of % d. \ N ", birthday. year, sum_day );
Return 0;
}
// Function Definition
Int checkyear (int n)
{
If (n % 4 = 0 & n % 100! = 0) | n % 400 = 0) // It is a leap year.
Return 0;
Else // year
Return 0;
}