1 #include<stdio.h> 2 3 int day_of_year(int year, int month, int day); 4 int main(void) 5 { 6 int year, month, day; 7 8 scanf_s("%d/%d/%d", &year, &month, &day); 9 10 printf("%d ", day_of_year(year, month, day)); 11 12 return 0; 13 } 14 int day_of_year(int year, int month, int day) 15 { 16 int tab[2][13] = { 17 {0,31,28,31,30,31,30,31,31,30,31,30,31}, 18 {0,31,29,31,30,31,30,31,31,30,31,30,31} 19 }; 20 21 int leap = 0; 22 23 if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) 24 { 25 leap = 1; 26 } 27 28 for (int i = 0; i < month; i++) 29 { 30 day = day + tab[leap][i]; 31 } 32 33 return day; 34 }