导读 #include #include #include struct ymd {int Y,M,D;};const short MonthDay[]={0,31,28,31,30,31,30,31,31,30,31,30,31};int YMD...
#include #include #include struct ymd {int Y,M,D;};const short MonthDay[]={0,31,28,31,30,31,30,31,31,30,31,30,31};int YMD_2_JD(int Y, int M, int D){const short MonthDay[]={0,31,28,31,30,31,30,31,31,30,31,30,31};int JD,i;JD=D;for (i=0;i2)) JD++; return JD;} void main(){int d,k;struct ymd a;printf("input Year Month day");k = scanf("%4d %2d %2d",&a.Y,&a.M,&a.D);if (k != 3) {printf("input err"); exit(0);};if (a.M < 1 || a.M > 12) {printf("err Month"); exit(0); };if ( (a.M==2) && (a.D==29) ) {if ( (a.Y%4==0)&&(a.Y%100!=0)||(a.Y%400==0)) {goto Lab;} else {printf("err Day"); exit(0); };}if (a.D < 1 || a.D > MonthDay[a.M]) {printf("err Day"); exit(0); };Lab:;if (a.Y < 0) {printf("negtive year"); exit(0);};d=YMD_2_JD(a.Y,a.M,a.D);printf("%d",d);exit(0);}。
免责声明:本文由用户上传,如有侵权请联系删除!