输出年历

来源:百度知道 编辑:UC知道 时间:2024/06/04 05:34:44
已知2000年1月1日为星期六,请输入任一年的年份后,打印该年的年历(注意闰年的情况)
格式如下:
当输入为:Input the year:2004
输出为:
The calendar of the year 2004.
Januray 1 February 2
Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat
1 2 3 1 2 3 4 5 6 7
4 5 6 7 8 9 10 8 9 10 11 12 13 14
11 12 13 14 15 16 17 15 16 17 18 19 20 21
18 19 20 21 22 23 24 22 23 24 25 26 27 28
25 26 27 28 29 30 31 29
=========================== ===========================
March 3 April 4
Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 1 2 3
7 8 9 10 11 12 13 4 5 6 7 8 9 10
14 15 16 17 18 19 20 11 12 13 14 15 16 17
21 22 23 24 25 26 27 18 1

======================
忘了从哪儿保存下来的了,
已经编译运行确认过。

#include <stdio.h>
#include <stdlib.h>
int leap(int); /*判断是否为闰年*/
int md(int m,int y); /*返回本月的天数*/
void prtweek(void); /*输出表头*/
int fw(int m,int y); /*返回本月一号是星期几*/
void prtmonth(int m); /*输出月份表头*/
int main(void)
{
int y,m,i,test,week;
printf("please import year of you want to select : ");
scanf("%d",&y);
for (m=1; m<=12; m++) {
test=1;
prtmonth(m);
prtweek();
week=fw(m,y);
if (week!=6)
for (i=0; i<=week; i++) {
putchar('\t');
test++;
}
for (i=1; i<=md(m,y); i++,test++) {
printf("%d\t",i);
if (test%7==0) {
putchar('\n');
}
}
putchar('\n');

system("pause");//暂停,以便观察输出
}
return 0;
}
int leap(int y)
{
retu