Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Prioject 19 - Counting Sundays
//fpc 3.0.0 program Project19; var d,m,y,n : integer; s: integer; a:array[1..13] of integer; // Program that counts "how many sundays that fell on the first day of the month in the XX centory are there" // You can adjust : // (1) The first day (which also determines which day in a week we will count) // (2) The starting year // (3) The finishing year // (4) The condition // to count the number of anyday in a week that fell on any day of a month (first day,second day,..) in any // period of time begin a[1]:=31; // Days in a month a[2]:=28; a[3]:=31; a[4]:=30; a[5]:=31; a[6]:=30; a[7]:=31; a[8]:=31; a[9]:=30; a[10]:=31; a[11]:=30; a[12]:=31; a[13]:=29; s:=0; d:=7;m:=1;y:=1900; // First sunday : 7/1/1990 repeat if y>1900 then if d=1 then begin inc(s);writeln(d,'-',m,'-',y);end; // If the day belongs to the XX centory (1901-2000) and is the first day of the month (d=1) then count d:=d+7;n:=m; if m=2 then if (y mod 400 = 0) then n:=13; if m=2 then if (y mod 100 <> 0) then if (y mod 4 =0) then n:=13; if d>a[n] then begin d:=d-a[n];inc(m);end; if m>12 then begin m:=1;inc(y);end; until y>2000; // (1) Count if correct --> (2) Next sunday --> (3) Check if it's in the XX centory --> (1) writeln(s); end.
run
|
edit
|
history
|
help
0
2sdfghkl
Deskripsi
digits_count
practica 7 ejercicio 4
practica 11 ejercicio 4
2
fff
zadacha6
Tugas1
Task 3b