2829 Almanaque
int semana (int y, int m, int d);
void main()
{
int mes día【12】= {31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31}
int y, w, I, m= 1, d=1
Printf("Ingrese el año yyyy: \n");
scanf("d", ampy
if); ( y 4 = = 0 amp; ampy100! = 0) mes día [1] = 29
for (m = 1; m lt = 12; m )
{ p; >
printf ("\n d año, d mes\n", y, m
printf ("S M T w T F S \n"); = 1; d lt = día del mes [m-1];
{
w = semana (y, m, d
if); (d == 1)
{
for(I = 0; i ltw; i ) printf ("");
if(d lt;10) printf("d",d);
si no printf("d",d);
if(w==6 ) printf("\n");
}
}
}
semana entera(entero y, entero m, entero d )
{
int w;
si ((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);
}
Los resultados de ejecución son los siguientes:
p>
Ingrese el año yyyy:
2001
2001, enero
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, febrero
S M T w V 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, miércoles mes
S M T w V 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, abril
S M T w V F S p>
1 2 3 4 5 6 7
8 9 10 11 12 13 14
<p>15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
2001, mayo
S M T w V 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, junio
S L T w V 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, julio
S M T w V 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, agosto
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 p>
19 20 21 22 23 24 25
26 27 28 29 30 31
2001, septiembre
S M T w V 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, octubre
S M T w V 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
Noviembre de 2001
S M T w V 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 febrero p>
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 31Presiona cualquier tecla para continuar...