18 条题解
-
0
#include #include #include using namespace std;
bool is_triangle(int a, int b, int c) { return (a + b > c) && (a + c > b) && (b + c > a); }
string triangle_type(int a, int b, int c) { if (a == b && b == c) { return "Equilateral triangle"; } else if (a == b || a == c || b == c) { return "Isosceles triangle"; } else if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) { return "Right triangle"; } else if (a * a + b * b < c * c || a * a + c * c < b * b || b * b + c * c < a * a) { return "Obtuse triangle"; } else { return "Acute triangle"; } }
int main() { int a, b, c; cin >> a >> b >> c; vector result; if (is_triangle(a, b, c)) { result.push_back(triangle_type(a, b, c)); } else { result.push_back("Not triangle"); } for (const auto &r : result) { cout << r << endl; } return 0; }
信息
- ID
- 626
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- (无)
- 递交数
- 263
- 已通过
- 120
- 上传者