Skip to content

Instantly share code, notes, and snippets.

@tischsoic
Created January 26, 2015 00:08
Show Gist options
  • Save tischsoic/a7db58f64359eac1d7b6 to your computer and use it in GitHub Desktop.
Save tischsoic/a7db58f64359eac1d7b6 to your computer and use it in GitHub Desktop.
Program Kalendarz;
function jakiDzien(d, m, r : integer) : integer;
var n : integer;
begin
n := 6 + d + r - 1900 + (r - 1900) div 4;
case m of
4, 7: ;
1, 10: n := n + 1;
5: n := n + 2;
8: n := n + 3;
2, 3, 11: n := n + 4;
6: n := n + 5;
9, 12: n := n + 6;
end;
if((r mod 4) = 0) and (m < 3) then n := n - 1;
jakiDzien := n mod 7;
end;
function ilePiatkow13() : integer;
var i, j : integer;
begin
ilePiatkow13 := 0;
for i := 2007 to 2011 do
begin
for j := 1 to 12 do
begin
if jakiDzien(13, j, i) = 5 then Inc(ilePiatkow13);
end;
end;
end;
var
i : integer;
begin
Writeln(ilePiatkow13());
Readln(i);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment