Problem D: 结构体:计算输入日期是该年的第几天
#include <stdio.h> struct time{ int year; int month; int day;}; int main(void) { struct time s1; int n; while(scanf("%d-%d-%d",&s1.year,&s1.month,&s1.day)!=EOF) { if(s1.year%4==0||s1.year%400==0) { if(s1.month==1) printf("%d\n",s1.day); if(s1.month==2) printf("%d\n",s1.day+31); if(s1.month==3) printf("%d\n",s1.day+31+29); if(s1.month==4) printf("%d\n",s1.day+31+29+31); if(s1.month==5) printf("%d\n",s1.day+31+29+31+30); if(s1.month==6) printf("%d\n",s1.day+31+29+31+30+31); if(s1.month==7) printf("%d\n",s1.day+31+29+31+30+31+30); if(s1.month==8) printf("%d\n",s1.day+31+29+31+30+31+30+31); if(s1.month==9) printf("%d\n",s1.day+31+29+31+30+31+30+31+31); if(s1.month==10) printf("%d\n",s1.day+31+29+31+30+31+30+31+31+30); if(s1.month==11) printf("%d\n",s1.day+31+29+31+30+31+30+31+31+30+31); if(s1.month==12) printf("%d\n",s1.day+31+29+31+30+31+30+31+31+30+31+30); } else { if(s1.month==1) printf("%d\n",s1.day); if(s1.month==2) printf("%d\n",s1.day+31); if(s1.month==3) printf("%d\n",s1.day+31+28); if(s1.month==4) printf("%d\n",s1.day+31+28+31); if(s1.month==5) printf("%d\n",s1.day+31+28+31+30); if(s1.month==6) printf("%d\n",s1.day+31+28+31+30+31); if(s1.month==7) printf("%d\n",s1.day+31+28+31+30+31+30); if(s1.month==8) printf("%d\n",s1.day+31+28+31+30+31+30+31); if(s1.month==9) printf("%d\n",s1.day+31+28+31+30+31+30+31+31); if(s1.month==10) printf("%d\n",s1.day+31+28+31+30+31+30+31+31+30); if(s1.month==11) printf("%d\n",s1.day+31+28+31+30+31+30+31+31+30+31); if(s1.month==12) printf("%d\n",s1.day+31+28+31+30+31+30+31+31+30+31+30); } } return 0; }