Muestra un calendario con el mes indicado
pascal:
Program calendario;
uses
crt;
var
a: word;
m: byte;
procedure cal(m:byte; a:word);
var
d,k,df : byte;
n : integer;
begin
case m of
1: df := 31;
2: if (a mod 4 = 0) and (a mod 100 <> 0) or (a mod 400 = 0) then
df := 29
else
df := 28;
3: df := 31;
4: df := 30;
5: df := 31;
6: df := 30;
7: df := 31;
8: df := 31;
9: df := 30;
10:df := 31;
11:df := 30;
12:df := 31
end;
d:=1;
if m<3 then
n:= a + 31 * (m - 1) + d * (a - 1) div 4 - 3 * ((a + 99) div 100) div 4
else
n:= a + 31 * (m - 1) + d - 4 * (m + 23) div 10 + a div 4 - (3 * (a div 100 + 1)) div 4 - 1;
n:= n mod 7;
clrscr;
gotoxy(18,3);
writeln('D L M M J V S');
k:=5;
repeat
gotoxy(19+3*(n-1),k);
write(d:3);
n:=(n+1) mod 7;
if n = 0 then inc(k);
inc(d)
until d>df;
readln
end;
begin
clrscr;
write('Fecha(mm aaaa):');
readln(m,a);
cal(m,a)
end.
uses
crt;
var
a: word;
m: byte;
procedure cal(m:byte; a:word);
var
d,k,df : byte;
n : integer;
begin
case m of
1: df := 31;
2: if (a mod 4 = 0) and (a mod 100 <> 0) or (a mod 400 = 0) then
df := 29
else
df := 28;
3: df := 31;
4: df := 30;
5: df := 31;
6: df := 30;
7: df := 31;
8: df := 31;
9: df := 30;
10:df := 31;
11:df := 30;
12:df := 31
end;
d:=1;
if m<3 then
n:= a + 31 * (m - 1) + d * (a - 1) div 4 - 3 * ((a + 99) div 100) div 4
else
n:= a + 31 * (m - 1) + d - 4 * (m + 23) div 10 + a div 4 - (3 * (a div 100 + 1)) div 4 - 1;
n:= n mod 7;
clrscr;
gotoxy(18,3);
writeln('D L M M J V S');
k:=5;
repeat
gotoxy(19+3*(n-1),k);
write(d:3);
n:=(n+1) mod 7;
if n = 0 then inc(k);
inc(d)
until d>df;
readln
end;
begin
clrscr;
write('Fecha(mm aaaa):');
readln(m,a);
cal(m,a)
end.