万年历,格式参考日历,可以打印出一定范围年份的全年日历(忘记是什么范围了。。题目找不到啦。。。aaaaaaa)
#include<stdio.h>
int is_rn(int x)
{
if((x%4==0&&x%100!=0)||(x%400==0))
return 1;
else
return 0;
}
int main()
{
int i,j,n,xqj,sum;
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int kgs;
while(scanf("%d",&n)==1)
{
sum=0;
if(n>1990)
{
for(i=1990;i<n;i++)
{
if(is_rn(i))
sum+=366;
else
sum+=365;
}
xqj=(sum%7+1)%7;
if(xqj==0)
xqj=7;
}
else if(n==1990)
xqj=1;
else if(n<1990)
{
for(i=1989;i>=n;i--)
{
if(is_rn(i))
sum+=366;
else
sum+=365;
}
xqj=sum%7;
if(xqj==0)
xqj=1;
else
xqj=8-xqj;
}
if(is_rn(n))
month[1]=29;
else
month[1]=28;
for(i=0;i<12;i++)
{
printf("*Mon Tue Wed Thu Fri Sat Sun\n");
kgs=(xqj-1)*4;
for(j=0;j<kgs;j++)
printf(" ");
for(j=1;j<=month[i];j++)
{
printf("%4d",j);
if(xqj%7==0)
{
xqj=1;
printf("\n");
}
else
xqj++;
}
if(xqj!=1)
printf("\n");
}
}
return 0;
}