Skip to content

Commit 0be7c34

Browse files
committed
Create 1344.时钟指针的夹角.js
1 parent 3c094f6 commit 0be7c34

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

1344.时钟指针的夹角.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {number} hour
3+
* @param {number} minutes
4+
* @return {number}
5+
*/
6+
var angleClock = function(hour, minutes) {
7+
const a = (hour % 12) * 30 + (minutes / 2);
8+
const b = minutes * 6;
9+
const result = Math.abs(b - a);
10+
if (result <= 180) {
11+
return result;
12+
} else {
13+
if (a > 180) {
14+
return 360 - a + b;
15+
} else {
16+
return 360 - b + a;
17+
}
18+
}
19+
};

0 commit comments

Comments
 (0)