Traditional Culture Encyclopedia - Almanac inquiry - 2829 yellow calendar

2829 yellow calendar

# contains "stdio.h"

int week(int y,int m,int d);

void main()

{

int month day【 12】= { 3 1,28,3 1,30,3 1,30,3 1,30,3 1,30,3 1 };

int y,w,I,m= 1,d= 1

Printf ("Please enter the year 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 year,% d month \ n", y, m);

printf(“S M T w T F S \ n“);

for(d = 1; d & lt= month day【m- 1】; d++)

{

W = week (y, m, d);

if(d = = 1)

{

for(I = 0; I & ltw;; i++)printf(““);

}

if(d & lt; 10)printf(“% d“,d);

else printf(“% d“,d);

if(w = = 6)printf(“\ n“);

}

}

}

Integer week (integer y, integer m, integer 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;

Return (w);

}

The running results are as follows:

Please enter the year yyyy:

200 1

200 1 year, 1 month

S M T w T F S

1 2 3 4 5 6

7 8 9 10 1 1 12 13

14 15 16 17 18 19 20

2 1 22 23 24 25 26 27

28 29 30 3 1

200 1, February

S M T w T F S

1 2 3

4 5 6 7 8 9 10

1 1 12 13 14 15 16 17

18 19 20 2 1 22 23 24

25 26 27 28

200 1, March

S M T w T F S

1 2 3

4 5 6 7 8 9 10

1 1 12 13 14 15 16 17

18 19 20 2 1 22 23 24

25 26 27 28 29 30 3 1

200 1, April

S M T w T F S

1 2 3 4 5 6 7

8 9 10 1 1 12 13 14

15 16 17 18 19 20 2 1

22 23 24 25 26 27 28

29 30

200 1, May

S M T w T F S

1 2 3 4 5

6 7 8 9 10 1 1 12

13 14 15 16 17 18 19

20 2 1 22 23 24 25 26

27 28 29 30 3 1

200 1, June

S M T w T F S

1 2

3 4 5 6 7 8 9

10 1 1 12 13 14 15 16

17 18 19 20 2 1 22 23

24 25 26 27 28 29 30

200 1, July

S M T w T F S

1 2 3 4 5 6 7

8 9 10 1 1 12 13 14

15 16 17 18 19 20 2 1

22 23 24 25 26 27 28

29 30 3 1

200 1, August

S M T w T F S

1 2 3 4

5 6 7 8 9 10 1 1

12 13 14 15 16 17 18

19 20 2 1 22 23 24 25

26 27 28 29 30 3 1

200 1, September

S M T w T F S

1

2 3 4 5 6 7 8

9 10 1 1 12 13 14 15

16 17 18 19 20 2 1 22

23 24 25 26 27 28 29

30

200 1 year,1month

S M T w T F S

1 2 3 4 5 6

7 8 9 10 1 1 12 13

14 15 16 17 18 19 20

2 1 22 23 24 25 26 27

28 29 30 3 1

200 1 year, 1 1 month

S M T w T F S

1 2 3

4 5 6 7 8 9 10

1 1 12 13 14 15 16 17

18 19 20 2 1 22 23 24

25 26 27 28 29 30

200 1, 65438+ February

S M T w T F S

1

2 3 4 5 6 7 8

9 10 1 1 12 13 14 15

16 17 18 19 20 2 1 22

23 24 25 26 27 28 29

30 3 1 Please press any key to continue. ...