c语言阳历
int week(int y,int m,int d);
void main()
{
int month day[12]= { 31,28,31,30,31,30,31,30,31,30,31 };
int y,w,I,m=1,d = 1;
Printf("请输入年份yyyy:\ n ");
scanf("%d ",& ampy);
if(y % 4 = = 0 & amp;& ampy%100!= 0)month day[1]= 29;
for(m = 1;m & lt=12;m++)
{
Printf("\n %d年,%d月\n ",y,m);
printf(" S M T w T F S \ n ");
for(d = 1;d & lt= month day[m-1];d++)
{
w =周(y,m,d);
如果(d==1)
{
for(I = 0;我& ltw;i++)printf(" ");
}
if(d & lt;10) printf("%d ",d);
else printf("%d ",d);
if(w = = 6)printf(" \ n ");
}
}
}
int week (int y,int m,int d)
{
int w;
if((m==1)||(m==2))
{
y-;
m+= 12;
}
w =(d+2 * m+3 *(m+1)/5+y+y/4-y/100+y/400+1)% 7;
返回(w);
}
运行结果如下:
请输入年份yyyy:
2001
2001年,1月
S M T w T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
2001,二月
S M T w T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28
2001,三月
S M T w T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
2001,四月
S M T w T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
2001,五月
S M T w T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
2001,六月
S M T w T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
2001,七月
S M T w T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
2001,八月
S M T w T F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
2001,九月
S M T w T F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
2001年,10月
S M T w T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
2001年,11月
S M T w T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
2001,65438+二月
S M T w T F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31请按任意键继续...