| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 518 人关注过本帖
标题:[求助]明天急用!帮我改一下
取消只看楼主 加入收藏
happyyu
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2005-4-10
收藏
 问题点数:0 回复次数: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月的 其他月分的没有

2005-08-25 22:39
快速回复:[求助]明天急用!帮我改一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.061139 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved