给出三个整数 a
, b
, c
, 如果它们可以构成三角形,返回 true
.
样例
样例 1:
输入 : a = 2, b = 3, c = 4
输出 : true
样例 2:
输入 : a = 1, b = 2, c = 3
输出 : false
注意事项
三角形的定义 (Wikipedia)
class Solution {
public:
/**
* @param a: a integer represent the length of one edge
* @param b: a integer represent the length of one edge
* @param c: a integer represent the length of one edge
* @return: whether three edges can form a triangle
*/
bool isValidTriangle(int a, int b, int c) {
// write your code here
if(a+b>c && a+c>b && b+c>a)
return true;
return false;
}
};