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

What's wrong with my program? Please,help me!!!
Posted by Revenger and NSC 29 Dec 2001 18:12
My code:

program t1070;{$N+}

var t1,t2,o1,o2  :extended;
    Str          :string;
    i,j          :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 j:=0 to 5 do
for i:=-j to j do begin
 if abs(time(t1,t2,i)-time(o1,o2,-i))<0.2666667 then begin
  writeln(abs(i));
  halt(0);
 end;
end;
end.