#include <stdio.h> #include <stdlib.h>/* enter month and date, the day of the year that the output is dated. Year greater than 1900*/int monthdays[12] = {N, a, A, a, a, a, a, a, a, a, a, a};int isgoodyear (int year); int Isgoodmont H (int month), int isgoodday (int year,int month,int day), int isleapyear (int), int dayofyear (int, int month, Int. Day int main () {int year, month, Day;while (Fflush (stdin), scanf ("%d%d%d", &year, &month, &day)! = EOF) {if (Isgoo Dyear (year) && Isgoodmonth (month) && Isgoodday (year, month, day)//Determine if the input is legitimate printf ("%d\n", DayOfYear ( (month, day)); elseprintf ("Please input a right date.\n");} System ("pause"); return 0;} int dayofyear (int, int, month, int day) {//The first days of the year int total = 0;for (int i = 0; i < month-1; ++i) Total + = monthdays[ I];total + = Day;if (Isleapyear (year) && (Month > 2)) Total++;return total; int isleapyear (int year) {if ((year% 4 = = 0) && (year% 100! = 0)) | | (Year% 400 = = 0)) return 1;elsereturn 0;} int isgoodyear (int year) {if (yeaR >= 1900) return 1;elsereturn 0;} int isgoodmonth (int month) {if ((month >= 1) && (month <=)) return 1;elsereturn 0;} int Isgoodday (int year, Int. month, int day) {switch (month) {Case 2:if (isleapyear (year)) if (day >= 1) && lt;=) return 1;else if ((Day >= 1) && (day <=)) return 1;elsereturn 0;case 4:case 6:case 9:case 11:if ( (Day >= 1) && (day <=)) return 1;elsereturn 0;case 1:case 3:case 5:case 7:case 8:case 10:case 12:if ( >= 1) && (day <=)) return to 1;elsereturn 0;default:printf ("Month error in day judge.\n"); return 0;}}
The day ordinal of a year