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 1070. Local Time

Why I get WA? Pelase, help me!!!!!!!
Posted by Nazarov Denis (nsc2001@rambler.ru) 21 Dec 2001 20:20
There is my program:

program t1070;

var t1,t2,o1,o2  :extended;
    Str          :string;
    i            :integer;

procedure makeIt(var x1,x2:extended;S:string);
var y1,y2,i :integer;
    sr      :string;
 begin
  i:=0;
  while s[i+1]=' ' do i:=i+1;
  sr:='';sr:=sr+s[i+1];sr:=sr+s[i+2]; val(sr,y1,i);
  sr:='';sr:=sr+s[i+4];sr:=sr+s[i+5]; val(sr,y2,i);
   x1:=y1+y2/60;
  i:=i+6;
  while s[i+1]=' ' do i:=i+1;
  sr:='';sr:=sr+s[i+1];sr:=sr+s[i+2]; val(sr,y1,i);
  sr:='';sr:=sr+s[i+4];sr:=sr+s[i+5]; val(sr,y2,i);
   x2:=y1+y2/60;
 end;

Function Time(t1,t2,r:extended):extended;
var r1,r2 :extended;
 begin
  r1:=t1;
  r2:=t2+r;
  if r1>r2 then r2:=r2+24;
  time:=r2-r1;
 end;

begin
Readln(Str);makeIt(t1,t2,str);
Readln(Str);makeIt(o1,o2,str);
for i:=-5 to 5 do begin
 if abs(time(t1,t2,i)-time(o1,o2,-i))<0.2666667 then
  break;
end;
writeln(abs(i));
end.