Skip to content

Instantly share code, notes, and snippets.

@WeiChiaChang
Created March 24, 2022 02:03
Show Gist options
  • Save WeiChiaChang/fe7f22e652a22cf16ee3a979e12b82ff to your computer and use it in GitHub Desktop.
Save WeiChiaChang/fe7f22e652a22cf16ee3a979e12b82ff to your computer and use it in GitHub Desktop.
q2.js
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