WEB开发网
开发学院软件开发C++ 打印日历 阅读

打印日历

 2008-03-08 12:39:52 来源:WEB开发网   
核心提示:#include<stdio.h>#include<conio.h>main(){int i=0,m=0,k,j,n=0,l,first;int x[3]={1,25,50},y=1;int day(int);int a[2][13]={{31,28,31,30,31,30,31,31,30,3
#include<stdio.h>
#include<conio.h>
main()
{int i=0,m=0,k,j,n=0,l,first;
int x[3]={1,25,50},y=1;
int day(int);
int a[2][13]={{31,28,31,30,31,30,31,31,30,31,30,31},
    {31,29,31,30,31,30,31,31,30,31,30,31}};
PRintf("\n\nplease input the year:");
scanf("%d",&i); l=i;
first=day(i);
if(i%4==0)k=1;
else k=0;
i=0;
while(m++<2)
{clrscr();
printf("                %d",l);
 for(;i<6*m;i++)
{
if(i<6)y=(i/3)*8+2; else y=((i-6)/3)*8+2 ;
gotoxy(x[i%3],y);
printf("     %d",i+1);
gotoxy(x[i%3],++y);
printf(" su mo tu we th fr sa");
gotoxy(x[i%3],++y);
for(n=0;n<first;n++)
printf("  ");
for(j=1;j<=a[k][i];j++)
{printf("%3d",j);
if((first+j)%7==0)
gotoxy(x[i%3],++y);} first=(first+a[k][i])%7;
}  if(m==1) printf("\n\nany key to continue");
  else printf("\n\nAny key to end");
getch();   }
}
day(int i)
{int k,s=0;
if(i>2000)
{for(k=2000;k<i;k++)
if(k%4==0) s=s+366;
else s=s+365;
return((s+6)%7);}
else if(i=2000) return(5);
   else
   {for(k=i;k<2000;k++)
   if(k%4==0)s=s+366;
   else s=s+365;
   return(7-(s+6)%7);}
  } 

Tags:打印 日历

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接