Created
March 24, 2022 02:03
-
-
Save WeiChiaChang/fe7f22e652a22cf16ee3a979e12b82ff to your computer and use it in GitHub Desktop.
q2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isInValidTriangle (a, b, c) { | |
const result = !((a+b)>c) || !((b+c)>a) || !((c+a)>b) || | |
!((a-b)<c) || !((b-a)<c) || !((b-c)<a) || !((c-b)<a) ||!((c-a)<b) || | |
!((a-c)<b) || !(a>0) || !(b>0) || !(c>0) | |
return result | |
} | |
if (isInValidTriangle(a, b, c)) { | |
console.log ('invalid') | |
} else if (a===b && b===c) { | |
console.log ('等邊三角形') | |
} else if ((a===b && b!==c) || (b===c && c!==a) || (c===a && a!==b)) { | |
console.log ('等腰三角形') | |
} else { | |
console.log('不等邊三角形') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment