program ZellersCongurence; uses crt; var infile,outfile:text; x:integer; s, ms, ds, ys:string; dd,mm,yy,e,dw:integer; function DayOfWeek (Day,Month,Year:integer): integer; var Century:integer; DOW:integer; begin if Month < 3 then begin Year := Year - 1; Month := Month + 12; end; Century := Year div 100; Year := Year mod 100; DOW := (((26*(Month+1)) div 10) + Day + Year + (Year div 4) + (Century div 4) - 2*Century) mod 7; if DOW<0 then DOW:=DOW+7; DayOfWeek := DOW; end; begin assign(infile,'DATA41.txt'); reset(infile); assign(outfile,'OUT41.txt'); rewrite(outfile); for x:=1 to 5 do begin readln(infile,s); ms:=copy(s,1,pos(' ',s)-1); delete(s,1,pos(' ',s)); ds:=copy(s,1,pos(',',s)-1); delete(s,1,pos(' ',s)); ys:=s; if ms='JANUARY' then mm :=1; if ms='FEBRUARY' then mm :=2; if ms='MARCH' then mm :=3; if ms='APRIL' then mm :=4; if ms='MAY' then mm :=5; if ms='JUNE' then mm :=6; if ms='JULY' then mm :=7; if ms='AUGUST' then mm :=8; if ms='SEPTEMBER' then mm :=9; if ms='OCTOBER' then mm :=10; if ms='NOVEMBER' then mm :=11; if ms='DECEMBER' then mm :=12; val(ds,dd,e); val(ys,yy,e); dw:=DayOfWeek(dd,mm,yy); if dw=0 then writeln(outfile,'SATURDAY'); if dw=1 then writeln(outfile,'SUNDAY'); if dw=2 then writeln(outfile,'MONDAY'); if dw=3 then writeln(outfile,'TUESDAY'); if dw=4 then writeln(outfile,'WEDNESDAY'); if dw=5 then writeln(outfile,'THURSDAY'); if dw=6 then writeln(outfile,'FRIDAY'); end; close(infile); close(outfile); end.