#include #include #include int yuefentianshu(int e,int a,int b)//e年份 a为月份,b为号数, { int p[12],i,c,sum; c=a-1; p[0]=31,p[1]=28,p[2]=31,p[3]=30,p[4]=31,p[5]=30,p[6]=31,p[7]=31,p[8]=30,p[9]=31,p[10]=30,p[11]=31; sum=0; for(i=0;i229) { sum++; return sum; } return sum; } int main() { printf("Please input what you want to known which year or which month or which day:\n"); int p[12],w[50],a,b,c,d,e,f,g,h,j,k,i,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,l,m,n,q,a1,a2,a3,yushu,q1,x,y,z,zhongjianliang; //年份a,月份b,号c,润了多少年d,月份天数e a=2019,b=1,c=11,q=0,j=0; l=a,m=b,n=c; i4=0;i5=0,i6=0,i7=0; yushu=5; p[0]=31,p[1]=28,p[2]=31,p[3]=30,p[4]=31,p[5]=30,p[6]=31,p[7]=31,p[8]=30,p[9]=31,p[10]=30,p[11]=31; char str[15],d1[15],d2[15],d3[15]; gets(str); for(i3=0;i3<=10;i3++) { if(str[i3]==32) { q++; } } if(q==0) { a=1940,b=1,c=1; while(str[i4]!=32) { i4++; } strncpy(d1,str+0,4); a1=atoi(d1); a2=1,a3=1; printf(" ============================%d============================\n\n",a1); for(i12=1;i12<=12;i12++) { a=1940,b=1,c=1; l=1940,m=1,n=1; x=a1,y=i12,z=a3; i13=i12; a1=l,i13=m,a3=n; a=x,b=y,c=z; e=yuefentianshu(a,b,c);//e大月份数天数 f=1; g=365; for(i2=a1+1;i2<=a-1;i2++) { if(i2%4==0&&i2%100!=0||i2%400==0) { j++;//闰年 } } if(a-a1==0) { k=e-f; } else if(a-a1==1) { k=e+g; } else { k=e+g+j*366+(a-a1-1-j)*365; } q1=k%7; if(q1==0) { i7=1; } else if(q1==1) { i7=2; } else if(q1==2) { i7=3; } else if(q1==3) { i7=4; } else if(q1==4) { i7=5; } else if(q1==5) { i7=6; } else if(q1==6) { i7=0; } if(y%4==0&&y%100!=0||y%400==0) { p[1]=29; } for(i8=1;i8<=p[y-1];i8++) { i9=i7+i8-1; w[i9]=i8; } for(i10=0;i10<=42;i10++) { if(i10i9) { w[i10]=0; } } printf(" ===========%d月============\n",y); printf(" SUN MON TUE WED THU FRI SAT\n ",y); printf(" "); for(i10=0;i10<=6;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=7;i10<=13;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=14;i10<=20;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=21;i10<=27;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=28;i10<=34;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=35;i10<=41;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); } } if(q==1) { a=1940,b=1,c=1; l=1940,m=1,n=1; while(str[i4]!=32) { i4++; } strncpy(d1,str+0,4); a1=atoi(d1); i5=i4+1; while(str[i4+1]!=0) { i4++; } strncpy(d2,str+i5,i4+1-i5); a2=atoi(d2); a3=1; x=a1,y=a2,z=a3; a1=l,a2=m,a3=n; a=x,b=y,c=z; e=yuefentianshu(a,b,c);//e大月份数天数 f=1; g=365; for(i2=a1+1;i2<=a-1;i2++) { if(i2%4==0&&i2%100!=0||i2%400==0) { j++;//闰年 } } if(a-a1==0) { k=e-f; } else if(a-a1==1) { k=e+g; } else { k=e+g+j*366+(a-a1-1-j)*365; } q1=k%7; if(q1==0) { i7=1; } else if(q1==1) { i7=2; } else if(q1==2) { i7=3; } else if(q1==3) { i7=4; } else if(q1==4) { i7=5; } else if(q1==5) { i7=6; } else if(q1==6) { i7=0; } if(y%4==0&&y%100!=0||y%400==0) { p[1]=29; } for(i8=1;i8<=p[y-1];i8++) { i9=i7+i8-1; w[i9]=i8; } for(i10=0;i10<=42;i10++) { if(i10i9) { w[i10]=0; } } printf(" ============%d月============\n",y); printf(" SUN MON TUE WED THU FRI SAT\n ",y); printf(" "); for(i10=0;i10<=6;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=7;i10<=13;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=14;i10<=20;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=21;i10<=27;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=28;i10<=34;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); printf(" "); for(i10=35;i10<=41;i10++) { if(w[i10]!=0) { printf(" %3d",w[i10]); } else { printf(" "); } } printf("\n"); } if(q==2) { while(str[i4]!=32) { i4++; } strncpy(d1,str+0,4); a1=atoi(d1); i5=i4+1; while(str[i4+1]!=32) { i4++; } strncpy(d2,str+i5,i4+1-i5); a2=atoi(d2); i6=i4+2; while(str[i4+2]!=0) { i4++; } strncpy(d3,str+i6,i4+2-i6); a3=atoi(d3); x=a1,y=a2,z=a3; if(ax||l==x&&m>y||l==x&&m==y&&n>z) { printf("距今天%d天",k); } else if(l==x&&m==y&&n==z)