10
1 2 3 4 5 6 7 8 9 10
2
9 10 1 2 3 4 5 6 7 8
2000 12 31
366
1 #include <stdio.h> 2 struct 3 { 4 int year; 5 int month; 6 int day; 7 }date; 8 9 int main() 10 { 11 int i,days; 12 int day_tab[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 13 //printf("input year,month,day:"); 14 scanf("%d %d %d",&date.year,&date.month,&date.day); 15 days=0; 16 for(i=1;i<date.month;i++) 17 days+=day_tab[i]; 18 days=days+date.day; 19 //闰年判断 20 if((date.year%4==0 && date.year%100!=0 || date.year%400==0) && date.month>=3) 21 days=days+1; 22 //printf("%d/%d is the %dth day in %d.\n",date.month,date.day,days,date.year); 23 printf("%d",days); 24 return 0; 25 }
原文:https://www.cnblogs.com/JIeJaitt/p/14805976.html