Traditional Culture Encyclopedia - The 24 Solar Terms - C language solar calendar
C language solar calendar
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 ");
}
}
}
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;
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. ...
- Related articles
- How to match the throttle of 20 10 BYD F6?
- Fortune teller, please help me calculate.
- What should we pay attention to in summer health?
- Art ppt material picture-how to make art courseware ppt
- Summer solar terms are too hot and humid, how to maintain health?
- When does the calendar query count as nine?
- What is suitable for planting in the backyard of rural hometown?
- The principle of hot air balloon landing
- How are the 24 solar terms divided into three categories?
- When people born in the Year of the Rabbit are in beginning of autumn, will their fate be good?