blob: 0bfa4ab26f86083b6a17dfdd212637a9e34e2004 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
Program ClockAngle;
(* *)
(* See ../README.md *)
(* *)
(* *)
(* Run as: fpc -och-2.out ch-2.p; ./ch-2.out < input-file *)
(* *)
uses sysutils;
var
time: string;
hours, minutes, angle: integer;
const
DIFF_PER_MINUTE = 11;
MIN_PER_HOUR = 60;
FULL_CIRCLE = 720;
begin
while not eof () do begin
(* *)
(* Read and parse the input. *)
(* *)
readln (time);
hours := strtoint (leftstr (time, 2));
minutes := strtoint (rightstr (time, 2));
(* *)
(* Calculate the angle in half degrees. *)
(* *)
angle := (DIFF_PER_MINUTE * (hours * MIN_PER_HOUR + minutes)) mod
FULL_CIRCLE;
(* *)
(* We want the convex angle. *)
(* *)
if 2 * angle >= FULL_CIRCLE then begin
angle := FULL_CIRCLE - angle;
end;
(* *)
(* Output. First we output the integer part. If the *)
(* number of half degrees is odd, add a trailing '.5'. *)
(* *)
write (angle div 2);
if angle mod 2 = 1 then begin
write ('.5');
end;
writeln ('');
end
end.
|