ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1201. Which Day Is It?

what is wrang. in wy proogram is all good
Posted by I am david. Tabo. 13 Apr 2002 18:20
if eniboby knous what is error? please help me, make a kindness.



const b:array [1..7] of string=
('mon','tue','wed','thu','fri','sat','sun');
      v:array [1..12] of shortint=
(31,28,31,30,31,30,31,31,30,31,30,31);

var data,month,year,q,l,t,r,m,n,i,j,k,x:integer;
    pir,pir1:string;
    d:array [1..7,1..7] of string;

procedure readdata;
  begin
    readln (data,month,year);
  end;

function leap(i:word):boolean;
  begin
    leap:=((i mod 4=0)and(i mod 100<>0))or(i mod 400=0);
  end;

procedure first_jan_of_year;
  begin
    j:=0;
    for i:=1 to year do
      begin
        if leap(i) then
          j:=(j+2) mod 7
        else
          j:=(j+1) mod 7;
      end;
  end;

procedure find_first_day;
  begin
    for i:=1 to month-1 do
      if (leap(year)) and (i=2) then
        k:=k+29
      else
        k:=k+v[i];
    if k<>0 then
      begin
        k:=k mod 7;
        if k=0 then
          k:=7;
      end;
    j:=(j+k) mod 7;
    if j=0 then
      j:=7;
    if year=1600 then
      j:=6;
  end;

procedure how_many_day_are_in_the_month;
  begin
    if (leap(year)) and (month=2) then
      x:=29
    else
      x:=v[month];
  end;

procedure weeks_days;
  begin
    d[1,1]:='mon';d[2,1]:='tue';d[3,1]:='wed';
    d[4,1]:='thu';d[5,1]:='fri';d[6,1]:='sat';d[7,1]:='sun';
  end;

procedure make_calendar;
  begin
    r:=0;
    for l:=2 to 7 do
      for i:=j to 7 do
        begin
          inc (r);
          if r>x then
            exit;
           str (r,d[i,l]);
           if r=data then
             if (length(d[i,l])=2) then
               d[i,l]:=' [' +d[i,l]+']'
             else
               d[i,l]:='  [' +d[i,l]+']'
           else
             begin
               if d[i,l-1]='' then
                 d[i,l]:='     ' +d[i,l]+' '
               else
                 begin
                   if length(d[i,l])=2 then
                     d[i,l]:='  ' +d[i,l]+' '
                   else
                     d[i,l]:='   ' +d[i,l]+' ';
                 end;
             end;
           if i=7 then
             j:=t+1;

        end;
  end;

procedure change;
  begin
    for i:=1 to 7 do
      for j:=1 to 7 do
        if d[i,j]='' then
          d[i,j]:='   ';
  end;

procedure print;
  begin
    for i:=1 to 7 do
      for j:=1 to 8 do
        if j>7 then
          writeln
        else
          write (d[i,j]);
  end;
begin
  readdata;
  first_jan_of_year;
  find_first_day;
  how_many_day_are_in_the_month;
  weeks_days;
  make_calendar;
  change;
  print;
end.


Re: what is wrang. in wy proogram is all good
Posted by Ivan Kazmenko (SPB SU FF) 14 Apr 2002 01:11
>              if (length(d[i,l])=2) then
>                d[i,l]:=' [' +d[i,l]+']'
>              else
>                d[i,l]:='  [' +d[i,l]+']'
I heard you should output ' [ '+d[i,l]+']'
 instead of               '  ['+d[i,l]+']'
(justifying the day in a field of 2 digits anyway, even if it has
one digit).
I may be wrong.