当前位置: 代码迷 >> C语言 >> [求助]明天急用!帮我改一下
  详细解决方案

[求助]明天急用!帮我改一下

热度:351   发布时间:2005-08-25 22:39:00.0
[求助]明天急用!帮我改一下

#include <stdio.h> main() {int y,m,d,t; clrscr(); printf("\ninput date:"); scanf("%d,%d,%d",&y,&m,&d); if(m!=0&&d!=0) x(y,m,d); if(m!=0&&d==0) month(y,m); if(m==0&&d==0) for(m=1;m<13;m++) {t=7*(m-1); gotoxy(36,t); month(y,m); } } int leapyear(int y) {if(y%4==0&&y%100!=0||y%400==0) return(1); else return(0); } month(int y,int m) {int N,n,i,j=3,s[45]={0},k; char *month[12]={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}; gotoxy(36,1); printf("%d ",y); printf("%s",month[m-1]); gotoxy(23,2); printf(" Sun Mon Tue Wed Thu Fri Sta"); N=1+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1; n=N%7; if(m==1||m==3||m==5||m==7||m==8||m==10||m==12) {gotoxy(23,j); for(k=0;k<5*n;k++) printf(" "); for(i=n;i<n+31;i++) {s[i]=i-n+1; printf("%5d",s[i]); if(i%7==6) gotoxy(23,++j); } } else if(m==4||m==6||m==9||m==11) {gotoxy(23,j++); for(k=0;k<5*n;k++) printf(" "); for(i=n;i<n+30;i++) {s[i]=i-n+1; printf("%5d",s[i]); if(i%7==6) gotoxy(23,j++); } } else if(m==2&&leapyear(y)==0) {gotoxy(23,j++); for(k=0;k<5*n;k++) printf(" "); for(i=n;i<n+28;i++) {s[i]=i-n+1; printf("%5d",s[i]); if(i%7==6) gotoxy(23,j++); } } else if(m==2&&leapyear(y)==1) {gotoxy(23,j++); for(k=0;k<5*n;k++) printf(" "); for(i=n;i<n+29;i++) {s[i]=i-n+1; printf("%5d",s[i]); if(i%7==6) gotoxy(23,j++); } } printf("\n"); } x (int y,int m,int d) {int N,z; if(m<3) N=d+2*(m+12)+3*(m+12+1)/5+(y-1)+(y-1)/4-(y-1)/100+(y-1)/400+1; else N=d+2*m+(3*(m+1)/5)+y+(y/4)-(y/100)+(y/400)+1; z=N%7;

switch(z) {case 0 : printf("This day is Sunday\n");break; case 1 : printf("This day is Monday\n");break; case 2 : printf("This day is Tuesday\n");break; case 3 : printf("This day is Wednesday\n");break; case 4 : printf("This day is Thursday\n");break; case 5 : printf("This day is Friday\n");break; case 6 : printf("This day is Saturday\n");break; }

} 年历功能有问题 输入2000,0,0 想得到2000年的日历 但是输出的结果只有2000年12月的 其他月分的没有


----------------解决方案--------------------------------------------------------
  相关解决方案