万年历C语言代码Word格式.docx
《万年历C语言代码Word格式.docx》由会员分享,可在线阅读,更多相关《万年历C语言代码Word格式.docx(5页珍藏版)》请在冰点文库上搜索。
intyear,month,a,b,c,m,n=28;
/*定义变量*/
longe;
printf("
请输入年份"
);
scanf("
%d"
&
year);
e=year;
e--;
/*前一年*/
e=(e*365+e/4)%7;
/*计算这一年的第一天是星期几*/
m=e;
/*把第一天的日期赋给m*/
if((year%4==0)||(year%100!
=0)&
&
(year%400!
=0))/*如果是闰年*/
n++;
%d的日历:
"
year);
for(month=1;
month<
=12;
month++)
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)/*这几个月每个月都是31天*/
c=0;
printf("
\n"
%d月\n"
month);
日一二三四五六\n"
for(b=1;
b<
=m;
b++)
c++;
"
/*从星期日开始到这个月开始的那天前都是空的*/
}
for(a=1;
a<
=31;
a++)
if(c%7-1==0&
c!
=1)/*判断一行是否已排满,满了就要换行*/
if(a<
10)/*如果是小于10,空一格,大于10,前后空*/
%d"
a);
m++;
if(m==7)/*一行排满,开始换行。
(指的是这个月的最后一行)*/
m=0;
else
if(month==4||month==6||month==9||month==11||month==2)
if(month==2)/*判断2月份*/
{
c=0;
printf("
c++;
printf("
=n;
if(c%7-1==0&
=1)
if(a<
10)
m++;
if(m==7)
m=0;
}
else
for(b=1;
{
c++;
printf("
}
for(a=1;
=30;
if(c%7-1==0&
if(a<
m++;
if(m==7)
m=0;
}