[Liuzy @ linux237 testcode] $ VI testhms. c
1 # include <stdio. h>
2 # include <stdlib. h>
3 # define hdg 30 // every 30 degrees of rotation in the hour hand
4 # define MDG 6 // The split needle is rotated for 6 degrees each time
5 # define SDG 6 // The second hand rotates for 6 degrees
6 int gethourdg (int h, int m)
7 {
8 int result = H * 30 + M * 0.5; // the minute hand turns 0.5 degrees 30/60 every time it is rotated.
9 return result;
10}
11
12 INT getminutedg (int m, int S)
13 {
14 return M * 6 + S * 0.5; // The second needle is rotated to 0.5 30/60 for each minute
15}
16
17 int getsecdg (int s)
18 {
19 Return S * 6;
20}
21
22 int main ()
23 {
24 For (INT I = 0; I <= 12; I ++)
25 {
26 For (Int J = 0; j <= 59; j ++)
27 {
28 For (int K = 0; k <= 59; k ++)
29 {
30 if (I> 12) I = i-12;
31 int hourdg = gethourdg (I, j) % 360;
32 int minutedg = getminutedg (j, k) % 360;
33 int secdg = getsecdg (k) % 360;
34 if (hourdg = minutedg) & (minutedg = secdg ))
35 {
36 printf ("hour = % d minute = % d Second = % d/N", I, j, k );
37}
38}
39}
40}
41
42}
~
[Liuzy @ linux237 testcode] $ g ++ testhms. c
Testhms. C: In function 'int gethourdg (INT, INT )':
Testhms. C: 8: Warning: Converting to 'int' from 'double'
Testhms. C: In function 'int getminutedg (INT, INT )':
Testhms. C: 14: Warning: Converting to 'int' from 'double'
[Liuzy @ linux237 testcode] $ A. Out
Hour = 0 minute = 0 second = 0
Hour = 12 minute = 0 second = 0
[Liuzy @ linux237 testcode] $
We can see from the result that the coincidence is two times, 0 points and 12 points respectively.