- UID
- 43952
注册时间2007-12-31
阅读权限10
最后登录1970-1-1
周游历练
TA的每日心情 | 怒 2015-11-21 19:12 |
---|
签到天数: 1 天 [LV.1]初来乍到
|
楼主 |
发表于 2010-12-12 10:07:34
|
显示全部楼层
万年历- int runnian(int nian)
- {
- if( ( nian%4==0 && nian%100!=0 ) || ( nian%400==0 && nian%4==0 && nian%100==0) )
- {
- return 1;
- }else{
- return 0;
- }
- }
- int yuetian(int nian,int i)
- {
- if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
- {
- return 31;
- }
- if(i==4 || i==6 || i==9 || i==11)
- {
- return 30;
- }
- if(i==2)
- {
- if(runnian(nian))
- {
- return 29;
- }else{
- return 28;
- }
- }
- }
- int fun(int nian,int yue)
- {
- int a,b,c,d,i,sum;
- a=b=c=d=i=sum=0;
- for(i=1;i<yue;i++)
- {
- d+=yuetian(nian,i);
- }
- d+=1;
- a=(nian-1)/4;
- b=(nian-1)/100;
- c=(nian-1)/400;
- sum=(nian-1)+a-b+c+d;
- if(sum%7)
- {
- return sum%7;
- }else{
- return 7;
- }
- }
- show(int xingqi,char shu)
- {
- int i,x=2,y=6,j,k=xingqi;
- clrscr();
- for(i=0;i<7;i++)
- {
- gotoxy(4+x,4);
- printf("%d",i+1);
- x+=4;
- }
- x=2;
- printf("\n------------------------------------------");
- for(j=1;j<=shu;j++)
- {
- gotoxy((4*xingqi)+x,y);
- printf("%d",j);
- x+=4;
- if(!(k%7))
- {
- xingqi=1;
- x=2;
- y++;
- k=0;
- }
- k++;
- }
- }
- main()
- {
- int nian,yue,shu;
- int i,xingqi;
- printf("qing shu ru ri qi(1990 5):");
- scanf("%d %d",&nian,&yue);
- shu=yuetian(nian,yue);
- xingqi=fun(nian,yue);
- show(xingqi,shu);
- }
复制代码 |
|