fork download
  1. program time;
  2. var
  3. H0, M0, H1, M1, inizio, fine, durata, ansH, ansM : longint;
  4.  
  5. begin
  6. {
  7.   uncomment the following lines if you want to read/write from files
  8.   assign(input, 'input.txt'); reset(input);
  9.   assign(output, 'output.txt'); rewrite(output);
  10. }
  11.  
  12. readln(H0, M0);
  13. readln(H1, M1);
  14.  
  15. inizio:=H0*60+M0;
  16. fine:=H1*60+M1;
  17. durata:=(fine-inizio) mod 1440;
  18. ansH:=durata div 60;
  19. ansM:= durata mod 60;
  20. if ansM<=0 then begin ansM:=ansM+60; ansH:=ansH -1;end;
  21. if ansM=60 then begin ansM:=0; ansH:=ansH+1; end;
  22. if ansH<=0 then ansH:=(ansH+24) mod 24;
  23. writeln (ansH,' ',ansM); { print result }
  24. end.
  25.  
Success #stdin #stdout 0s 5308KB
stdin
0 0
12 0


stdout
12 0