------------------------------------------------------------------------------
--Isso é um programa para calendário perpétuo em Ada 95.
--Autor: José Lauro Strapasson-Brazil-2002.
--Licensa:
--Esse programa pode ser distribuido livrimente desde que o nome do autor
--e essa licensa apareça no código fonte ou em outro arquivo de texto
--visivel incluido junto com a distribuição.
--O programa é distribuido "como é" sem nenhum tipo de garantia.
--Pode ser modificado livrimente desde que respeite essa licensa.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--No calendário gregoriano que é o que vamos seguir existem dois tipos de anos.
--Os anos comuns que tem 365 dias e os anos bisextos que tem 366 dias.
--Esse dia a mais é um 29 de fevereiro.
--No calendário gregoriano os anos multiplos de 4 são bisextos a principio.
--No entanto os anos multiplos de 100 que não forem multiplos de 400
--não são bisextos.
--Obs: No calendário juliano se não me engano, todos os anos multiplos de 4 são
--bisextos.
-------------------------------------------------------------------------------
------------------------------------------------------------------------------
--Exemplos de anos bisextos: 1976, 2000, 2004, 2008, 1980, etc.
--Exemplos de anos não bisextos: 2001, 1999 ,2100, 1900, 2200, etc.
--Os anos formam um ciclo de 400 anos. Mostraremos isso mais a frente.
--Assim o ano 2400 será bisexto e terá a mesma distribuição dos dias da semana
--que o ano 2000.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--Como uma semana tem 7 dias se a diferença de dias entre duas datas for
--de 7 ambas as datas terão o mesmo dia da semana.
--Ex: 21/05/76 era uma sexta feira.
--11/06/76 ou seja, 21 dias depois também era uma sexta feira.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--O calendário cristão passou a ser usado lá pelo século IV e ainda era o
--calendário juliano. O calendário gregoriano passou a ser usado bem mais
--tarde ainda. No entanto suponha que tenha havido o ano ZERO e que fosse já
--no calendário cristão gregoriano. Como a diferença entre 0 e 2000 é multiplo
--de 400 o nosso hipotético ano 0 seria como o ano 2000, ou seja, uma ano
--bisexto começando de sábado.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--Considere o ano 1991. Do ano 0 à 1991 teriamos
--1991*365 dias= 726715 dias.
--No entanto não levamos em conta os dias 29/02 de todos os anos bisextos.
--O ultimo ano bisexto antes de 1991 foi 1988. Dividindo isso por 4 obtemos
--497 anos multiplos de 4 e tirando os anos
--100,200,300,500,600,700,900,1000,1100,1300,1400,1500,1700,1800,1900.
--Temos que teria havido 482 anos bisextos.
--O total de dias seria então: 726715+482=727197 dias.
--Dividindo isso por 7 temos 103885 e um resto de 2 dias.
--Assim os dias da semana de uma data no ano 1991 e no ano 0 (e portanto no
--ano 2000 também) diferem por 2 dias a mais na data de 1991.
--Se o dia 29/02 do suposto ano 0 for relevante teriamos 3 dias de diferenca.
--Observe: 08/05/2000 foi uma segunda feira.
-- 08/05/1991 foi uma quarta feira.
--Logo nossa conta está certa.
--Já no entanto o dia 02/01/2000 foi um domingo.
--enquanto 02/01/1991 foi uma quarta feira.
--Ou seja, uma diferença de 3 dias pois o dia 29/02 do hipotético ano zero
--contou.
--Podemos usar esse mesmo método para mostrar que duas datas diferiando por
--400 anos tem uma diferença de dias multipla de 7. Ou seja, que o ciclo se
--repete a cada 400 anos.
--O numero de dias em primcipio é
--400x365=146000
--Existem no intervalo 100 anos multiplos de 4 dos quais 3 não são bisextos.
--Assim o numero de anos bisextos é 97.
--Total de dias é 146000 + 97 = 146097 que é divisivel por 7 dando 20871.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--Existem vários tipos de calendários perpétuos. Uns que dizem o dia da semana
--de uma dada data. Outros dizem a diferença de dias entre um ano e outro.
--Esse programa no entanto será diferente. Ele vai imprimir um calendário do
--dado ano pois acho isso mais util.
--Quanto aos dias da semana existem 14 tipos de anos possiveis.
--7 de acordo com o dia da semana que começam e isso vezes 2 de acordo com ser
--bisexto ou não.
--Para caracterizarmos um ano precisamos saber duas coisas.
--1) Se é bisexto ou não.
--2) O dia da semana de um dado dia do ano (usaremos 1 de janeiro).
--A pessoa deverá entrar o ano e o programa escrevera o calendário.
--Eu resolvi por já definido os 14 tipos de calendários possíveis pois me
--pareceu mais prático já que hoje em dia o mouse e a capacidade de copiar e
--colar tornam a vida bem mais fácil.
------------------------------------------------------------------------------
with text_IO, ada.integer_text_IO;
use text_IO, ada.integer_text_IO;
procedure dias is
arquivo:file_type;
procedure ano_1 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 1 2 3 4 ");
put_line(arquivo," 8 9 10 11 12 13 14 5 6 7 8 9 10 11 5 6 7 8 9 10 11 ");
put_line(arquivo,"15 16 17 18 19 20 21 12 13 14 15 16 17 18 12 13 14 15 16 17 18 ");
put_line(arquivo,"22 23 24 25 26 27 28 19 20 21 22 23 24 25 19 20 21 22 23 24 25 ");
put_line(arquivo,"29 30 31 26 27 28 26 27 28 29 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 6 1 2 3 ");
put_line(arquivo," 2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10 ");
put_line(arquivo," 9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17 ");
put_line(arquivo,"16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24 ");
put_line(arquivo,"23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30 ");
put_line(arquivo,"30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 1 2 3 ");
put_line(arquivo," 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10 ");
put_line(arquivo," 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17 ");
put_line(arquivo,"16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24 ");
put_line(arquivo,"23 24 25 26 27 28 29 27 28 29 30 31 25 26 27 28 29 30 ");
put_line(arquivo,"30 31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 1 2 ");
put_line(arquivo," 8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9 ");
put_line(arquivo,"15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16 ");
put_line(arquivo,"22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23 ");
put_line(arquivo,"29 30 31 26 27 28 29 30 24 25 26 27 28 29 30 ");
put_line(arquivo," 31 ");
end ano_1;
procedure ano_2 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 1 2 3 ");
put_line(arquivo," 7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10 ");
put_line(arquivo,"14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17 ");
put_line(arquivo,"21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24 ");
put_line(arquivo,"28 29 30 31 25 26 27 28 25 26 27 28 29 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 5 1 2 ");
put_line(arquivo," 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 ");
put_line(arquivo,"15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 15 14 16 ");
put_line(arquivo,"22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 ");
put_line(arquivo,"29 30 27 28 29 30 31 24 25 26 27 28 29 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 1 ");
put_line(arquivo," 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 ");
put_line(arquivo,"15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 ");
put_line(arquivo,"22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 ");
put_line(arquivo,"29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 ");
put_line(arquivo," 30 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 1 ");
put_line(arquivo," 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 ");
put_line(arquivo,"14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 ");
put_line(arquivo,"21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 ");
put_line(arquivo,"28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 ");
put_line(arquivo," 30 31 ");
end ano_2;
procedure ano_3 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 1 2 ");
put_line(arquivo," 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9 ");
put_line(arquivo,"13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16 ");
put_line(arquivo,"20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23 ");
put_line(arquivo,"27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30 ");
put_line(arquivo," 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 4 1 ");
put_line(arquivo," 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 ");
put_line(arquivo,"14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 ");
put_line(arquivo,"21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 ");
put_line(arquivo,"28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 ");
put_line(arquivo," 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 ");
put_line(arquivo," 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 ");
put_line(arquivo,"14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 ");
put_line(arquivo,"21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 ");
put_line(arquivo,"28 29 30 31 25 26 27 28 29 30 31 29 30 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 1 2 3 4 5 6 7 ");
put_line(arquivo," 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14 ");
put_line(arquivo,"13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21 ");
put_line(arquivo,"20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28 ");
put_line(arquivo,"27 28 29 30 31 24 25 26 27 28 29 30 29 30 31 ");
end ano_3;
procedure ano_4 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 1 ");
put_line(arquivo," 5 6 7 8 9 10 11 2 3 4 5 6 7 8 2 3 4 5 6 7 8 ");
put_line(arquivo,"12 13 14 15 16 17 18 9 10 11 12 13 14 15 9 10 11 12 13 14 15 ");
put_line(arquivo,"19 20 21 22 23 24 25 16 17 18 19 20 21 22 16 17 18 19 20 21 22 ");
put_line(arquivo,"26 27 28 29 30 31 23 24 25 26 27 28 23 24 25 26 27 28 29 ");
put_line(arquivo," 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 3 1 2 3 4 5 6 7 ");
put_line(arquivo," 6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14 ");
put_line(arquivo,"13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21 ");
put_line(arquivo,"20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28 ");
put_line(arquivo,"27 28 29 30 25 26 27 28 29 30 31 29 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 1 2 3 4 5 6 ");
put_line(arquivo," 6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13 ");
put_line(arquivo,"13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20 ");
put_line(arquivo,"20 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 27 ");
put_line(arquivo,"27 28 29 30 31 24 25 26 27 28 29 30 28 29 30 ");
put_line(arquivo," 31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 1 2 3 4 5 6 ");
put_line(arquivo," 5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13 ");
put_line(arquivo,"12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20 ");
put_line(arquivo,"19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27 ");
put_line(arquivo,"26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31 ");
put_line(arquivo," 30 ");
end ano_4;
procedure ano_5 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7 ");
put_line(arquivo," 4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14 ");
put_line(arquivo,"11 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21 ");
put_line(arquivo,"18 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28 ");
put_line(arquivo,"25 26 27 28 29 30 31 29 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 2 1 2 3 4 5 6 ");
put_line(arquivo," 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13 ");
put_line(arquivo,"12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 ");
put_line(arquivo,"19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 ");
put_line(arquivo,"26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 ");
put_line(arquivo," 31 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 1 2 3 4 5 ");
put_line(arquivo," 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12 ");
put_line(arquivo,"12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19 ");
put_line(arquivo,"19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26 ");
put_line(arquivo,"26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 ");
put_line(arquivo," 30 31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 ");
put_line(arquivo," 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12 ");
put_line(arquivo,"11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19 ");
put_line(arquivo,"18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26 ");
put_line(arquivo,"25 26 27 28 29 30 31 29 30 27 28 29 30 31 ");
end ano_5;
procedure ano_6 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 1 2 3 4 5 6 ");
put_line(arquivo," 3 4 5 6 7 8 9 7 8 9 10 11 12 13 7 8 9 10 11 12 13 ");
put_line(arquivo,"10 11 12 13 14 15 16 14 15 16 17 18 19 20 14 15 16 17 18 19 20 ");
put_line(arquivo,"17 18 19 20 21 22 23 21 22 23 24 25 26 27 21 22 23 24 25 26 27 ");
put_line(arquivo,"24 25 26 27 28 29 30 28 28 29 30 31 ");
put_line(arquivo,"31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 1 2 3 4 5 ");
put_line(arquivo," 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 ");
put_line(arquivo,"11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 ");
put_line(arquivo,"18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26 ");
put_line(arquivo,"25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 ");
put_line(arquivo," 30 31 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 2 3 4 5 6 7 1 2 3 4 ");
put_line(arquivo," 4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11 ");
put_line(arquivo,"11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18 ");
put_line(arquivo,"18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25 ");
put_line(arquivo,"25 26 27 28 29 30 31 29 30 31 26 27 28 29 30 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 1 2 3 4 ");
put_line(arquivo," 3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11 ");
put_line(arquivo,"10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18 ");
put_line(arquivo,"17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25 ");
put_line(arquivo,"24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31 ");
put_line(arquivo,"31 ");
end ano_6;
procedure ano_7 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 1 2 3 4 5 ");
put_line(arquivo," 2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12 ");
put_line(arquivo," 9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 19 ");
put_line(arquivo,"16 17 18 19 20 21 22 20 21 22 23 24 25 26 20 21 22 23 24 25 26 ");
put_line(arquivo,"23 24 25 26 27 28 29 27 28 27 28 29 30 31 ");
put_line(arquivo,"30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 7 1 2 3 4 ");
put_line(arquivo," 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11 ");
put_line(arquivo,"10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18 ");
put_line(arquivo,"17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25 ");
put_line(arquivo,"24 25 26 27 28 29 30 29 30 31 26 27 28 29 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 1 2 3 ");
put_line(arquivo," 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10 ");
put_line(arquivo,"10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17 ");
put_line(arquivo,"17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24 ");
put_line(arquivo,"24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30 ");
put_line(arquivo,"31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 1 2 3 ");
put_line(arquivo," 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10 ");
put_line(arquivo," 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17 ");
put_line(arquivo,"16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24 ");
put_line(arquivo,"23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31 ");
put_line(arquivo,"30 31 ");
end ano_7;
procedure ano_8 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 1 2 3 ");
put_line(arquivo," 8 9 10 11 12 13 14 5 6 7 8 9 10 11 4 5 6 7 8 9 10 ");
put_line(arquivo,"15 16 17 18 19 20 21 12 13 14 15 16 17 18 11 12 13 14 15 16 17 ");
put_line(arquivo,"22 23 24 25 26 27 28 19 20 21 22 23 24 25 18 19 20 21 22 23 24 ");
put_line(arquivo,"29 30 31 26 27 28 29 25 26 27 28 29 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 5 1 2 ");
put_line(arquivo," 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 ");
put_line(arquivo,"15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16 ");
put_line(arquivo,"22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 ");
put_line(arquivo,"29 30 27 28 29 30 31 24 25 26 27 28 29 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 1 ");
put_line(arquivo," 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 ");
put_line(arquivo,"15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 ");
put_line(arquivo,"22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 ");
put_line(arquivo,"29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 ");
put_line(arquivo," 30 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 1 ");
put_line(arquivo," 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 ");
put_line(arquivo,"14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 ");
put_line(arquivo,"21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 ");
put_line(arquivo,"28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 ");
put_line(arquivo," 30 31 ");
end ano_8;
procedure ano_9 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 1 2 ");
put_line(arquivo," 7 8 9 10 11 12 13 4 5 6 7 8 9 10 3 4 5 6 7 8 9 ");
put_line(arquivo,"14 15 16 17 18 19 20 11 12 13 14 15 16 17 10 11 12 13 14 15 16 ");
put_line(arquivo,"21 22 23 24 25 26 27 18 19 20 21 22 23 24 17 18 19 20 21 22 23 ");
put_line(arquivo,"28 29 30 31 25 26 27 28 29 24 25 26 27 28 29 30 ");
put_line(arquivo," 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 4 1 ");
put_line(arquivo," 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 ");
put_line(arquivo,"14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 ");
put_line(arquivo,"21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 ");
put_line(arquivo,"28 29 30 26 27 28 29 30 31 23 24 25 26 27 29 29 ");
put_line(arquivo," 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 ");
put_line(arquivo," 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 ");
put_line(arquivo,"14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 ");
put_line(arquivo,"21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 ");
put_line(arquivo,"28 29 30 31 25 26 27 28 29 30 31 29 30 ");
put_line(arquivo," ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 1 2 3 4 5 6 7 ");
put_line(arquivo," 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14 ");
put_line(arquivo,"13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21 ");
put_line(arquivo,"20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28 ");
put_line(arquivo,"27 28 29 30 31 24 25 26 27 28 29 30 29 30 31 ");
put_line(arquivo," ");
end ano_9;
procedure ano_10 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 1 ");
put_line(arquivo," 6 7 8 9 10 11 12 3 4 5 6 7 8 9 2 3 4 5 6 7 8 ");
put_line(arquivo,"13 14 15 16 17 18 19 10 11 12 13 14 15 16 9 10 11 12 13 14 15 ");
put_line(arquivo,"20 21 22 23 24 25 26 17 18 19 20 21 22 23 16 17 18 19 20 21 22 ");
put_line(arquivo,"27 28 29 30 31 24 25 26 27 28 29 23 24 25 26 27 28 29 ");
put_line(arquivo," 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 3 1 2 3 4 5 6 7 ");
put_line(arquivo," 6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14 ");
put_line(arquivo,"13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21 ");
put_line(arquivo,"20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28 ");
put_line(arquivo,"27 28 29 30 25 26 27 28 29 30 31 29 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 1 2 1 2 3 4 5 6 ");
put_line(arquivo," 6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13 ");
put_line(arquivo,"13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20 ");
put_line(arquivo,"20 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 27 ");
put_line(arquivo,"27 28 29 30 31 24 25 26 27 28 29 30 28 29 30 ");
put_line(arquivo," 31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 1 2 3 4 5 6 ");
put_line(arquivo," 5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13 ");
put_line(arquivo,"12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20 ");
put_line(arquivo,"19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27 ");
put_line(arquivo,"26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31 ");
put_line(arquivo," 30 ");
end ano_10;
procedure ano_11 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 1 2 3 4 5 6 7 ");
put_line(arquivo," 5 6 7 8 9 10 11 2 3 4 5 6 7 8 8 9 10 11 12 13 14 ");
put_line(arquivo,"12 13 14 15 16 17 18 9 10 11 12 13 14 15 15 16 17 18 19 20 21 ");
put_line(arquivo,"19 20 21 22 23 24 25 16 17 18 19 20 21 22 22 23 24 25 26 27 28 ");
put_line(arquivo,"26 27 28 29 30 31 23 24 25 26 27 28 29 29 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 2 1 2 3 4 5 6 ");
put_line(arquivo," 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13 ");
put_line(arquivo,"12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 ");
put_line(arquivo,"19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 ");
put_line(arquivo,"26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 ");
put_line(arquivo," 31 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 1 1 2 3 4 5 ");
put_line(arquivo," 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12 ");
put_line(arquivo,"12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19 ");
put_line(arquivo,"19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26 ");
put_line(arquivo,"26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 ");
put_line(arquivo," 30 31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 ");
put_line(arquivo," 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12 ");
put_line(arquivo,"11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19 ");
put_line(arquivo,"18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26 ");
put_line(arquivo,"25 26 27 28 29 30 31 29 30 27 28 29 30 31 ");
end ano_11;
procedure ano_12 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 ");
put_line(arquivo," 4 5 6 7 8 9 10 8 9 10 11 12 13 14 7 8 9 10 11 12 13 ");
put_line(arquivo,"11 12 13 14 15 16 17 15 16 17 18 19 20 21 14 15 16 17 18 19 20 ");
put_line(arquivo,"18 19 20 21 22 23 24 22 23 24 25 26 27 28 21 22 23 24 25 26 27 ");
put_line(arquivo,"25 26 27 28 29 30 31 29 28 29 30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 1 2 3 4 5 ");
put_line(arquivo," 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 ");
put_line(arquivo,"11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 ");
put_line(arquivo,"18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26 ");
put_line(arquivo,"25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 ");
put_line(arquivo," 30 31 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 1 2 3 4 5 6 7 1 2 3 4 ");
put_line(arquivo," 4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11 ");
put_line(arquivo,"11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18 ");
put_line(arquivo,"18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25 ");
put_line(arquivo,"25 26 27 28 29 30 31 29 30 31 26 27 28 29 30 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 1 2 3 4 ");
put_line(arquivo," 3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11 ");
put_line(arquivo,"10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18 ");
put_line(arquivo,"17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25 ");
put_line(arquivo,"24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31 ");
put_line(arquivo,"31 ");
end ano_12;
procedure ano_13 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 1 2 3 4 5 ");
put_line(arquivo," 3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12 ");
put_line(arquivo,"10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19 ");
put_line(arquivo,"17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26 ");
put_line(arquivo,"24 25 26 27 28 29 30 28 29 27 28 29 30 31 ");
put_line(arquivo,"31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 7 1 2 3 4 ");
put_line(arquivo," 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11 ");
put_line(arquivo,"10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18 ");
put_line(arquivo,"17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25 ");
put_line(arquivo,"24 25 26 27 28 29 30 29 30 31 26 27 28 29 30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 1 2 3 4 5 6 1 2 3 ");
put_line(arquivo," 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10 ");
put_line(arquivo,"10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17 ");
put_line(arquivo,"17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24 ");
put_line(arquivo,"24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30 ");
put_line(arquivo,"31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 1 2 3 ");
put_line(arquivo," 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10 ");
put_line(arquivo," 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17 ");
put_line(arquivo,"16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24 ");
put_line(arquivo,"23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31 ");
put_line(arquivo,"30 31 ");
end ano_13;
procedure ano_14 is
begin
put_line(arquivo," Janeiro Fevereiro Marco ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 1 2 3 4 ");
put_line(arquivo," 2 3 4 5 6 7 8 6 7 8 9 10 11 12 5 6 7 8 9 10 11 ");
put_line(arquivo," 9 10 11 12 13 14 15 13 14 15 16 17 18 19 12 13 14 15 16 17 18 ");
put_line(arquivo,"16 17 18 19 20 21 22 20 21 22 23 24 25 26 19 20 21 22 23 24 25 ");
put_line(arquivo,"23 24 25 26 27 28 29 27 28 29 26 27 28 29 30 31 ");
put_line(arquivo,"30 31 ");
new_line(arquivo);
put_line(arquivo," Abril Maio Junho ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 6 1 2 3 ");
put_line(arquivo," 2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10 ");
put_line(arquivo," 9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17 ");
put_line(arquivo,"16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24 ");
put_line(arquivo,"23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30 ");
put_line(arquivo,"30 ");
new_line(arquivo);
put_line(arquivo," Julho Agosto Setembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 1 2 3 4 5 1 2 ");
put_line(arquivo," 2 3 4 5 6 7 8 6 7 8 9 10 11 12 3 4 5 6 7 8 9 ");
put_line(arquivo," 9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16 ");
put_line(arquivo,"16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23 ");
put_line(arquivo,"23 24 25 26 27 28 29 27 28 29 30 31 24 25 26 27 28 29 30 ");
put_line(arquivo,"30 31 ");
new_line(arquivo);
put_line(arquivo," Outubro Novembro Dezembro ");
put_line(arquivo," D S T Q Q S S D S T Q Q S S D S T Q Q S S ");
put_line(arquivo," 1 2 3 4 5 6 7 1 2 3 4 1 2 ");
put_line(arquivo," 8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9 ");
put_line(arquivo,"15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16 ");
put_line(arquivo,"22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23 ");
put_line(arquivo,"29 30 31 26 27 28 29 30 24 25 26 27 28 29 30 ");
put_line(arquivo," 31 ");
end ano_14;
function ip(a,b:integer) return integer is
--Essa funcao da a parte inteira da divisão de a por b.
resultado:integer;
begin
resultado:=(a-(a mod b))/b;
return resultado;
end ip;
ano:integer;
ano_minimo:integer:=1583;
--O calendário gregoriano foi adotado no ocidente em outubro de 1582.
--Ainda hoje o calendário juliano é utilizado em paizes orintais como a Russia
--por exemplo.
--Na decada de 20 do século passado alguns cristãos ortodoxos ditos neocalendaristas
--adotaram um terceiro calendário que coincide com o gregoriano até o ano 2800.
--Esse programa por enquanto trata somente do calendário gregoriano.
--De 1 de março de 1900 à 29 de fevereiro de 2100 no calendário gregoriano, o
--o calendário juliano difere por 13 dias. Ex: 7 de janeiro no gregoriano
--é igual a 25/12 no juliano (Natal).
ano_bisexto:boolean;
anos_bisextos,delta_dias,fator_semana:integer;
nome_arquivo:string(1..99);
n:natural;
---------------Fim da declaração de variaveis.--------------------------------
begin
-----------------Inicio do programa propriamente dito.------------------------
---------------o ano como dado de entrada.-------------------------------------
loop
put_line("Entre um ano maior ou igual a " & integer'image(ano_minimo));
get(ano);
exit when ano>=ano_minimo;
end loop;
n:=0;
put_line("Entre o nome do arquivo para salvar o calendario");
put_line("Defaut: ano.txt");
get_line(nome_arquivo,n);
get_line(nome_arquivo,n);
--Não sei porque devo por isso duas vezes!
if n/=0 then
create(arquivo,out_file,nome_arquivo(1..n));
else
create(arquivo,out_file,"ano.txt");
end if;
-------------------bisexto?---------------------------------------------------
ano_bisexto:=false;
if (ano mod 4 =0 and ano mod 100 /= 0) or ano mod 400 = 0 then
ano_bisexto:=true;
end if;
--Precisamos descobrir que dia da semana será ou era 1 de janeiro do dado ano.
--Antes vejamos quantos anos bisextos tem entre o nosso ano e o ano 0.
anos_bisextos:=ip(ano,4)-ip(ano,100)+ip(ano,400);
--a funcao ip definida por mim pega a parte inteira da divisao dos dois numeros.
delta_dias:=ano * 365 + anos_bisextos +1;
--O 1 é do dia 29/02 do ano 0 pois consideramos dia 1 de janeiro.
fator_semana:=delta_dias mod 7;
if ano_bisexto=true then
fator_semana:=fator_semana-1;
end if;
--Isso para não incluir o proprio 29/02 casa seja bisexto pois o que interessa é 01/01.
if fator_semana<=0 then
fator_semana:=fator_semana+7;
elsif fator_semana>7 then
fator_semana:=fator_semana-7;
end if;
--Pronto! Fator_semana contem a diferença de dias para o dia 01/01/2000 que como era
--sabádo (=7) não precisa ser somado!
--Agora já sabemos o dia da semana que é ou será dia 01/01 e sabemos se o ano é bisexto ou não.
--Agora é só escrever o calendário.
if fator_semana=1 and ano_bisexto=false then ano_1;
elsif fator_semana=2 and ano_bisexto=false then ano_2;
elsif fator_semana=3 and ano_bisexto=false then ano_3;
elsif fator_semana=4 and ano_bisexto=false then ano_4;
elsif fator_semana=5 and ano_bisexto=false then ano_5;
elsif fator_semana=6 and ano_bisexto=false then ano_6;
elsif fator_semana=7 and ano_bisexto=false then ano_7;
elsif fator_semana=1 and ano_bisexto=true then ano_8;
elsif fator_semana=2 and ano_bisexto=true then ano_9;
elsif fator_semana=3 and ano_bisexto=true then ano_10;
elsif fator_semana=4 and ano_bisexto=true then ano_11;
elsif fator_semana=5 and ano_bisexto=true then ano_12;
elsif fator_semana=6 and ano_bisexto=true then ano_13;
elsif fator_semana=7 and ano_bisexto=true then ano_14;
end if;
close(arquivo);
end dias;
syntax highlighted by Code2HTML, v. 0.9