A29860号题解
2026-09-27 17:46:41
发布于:浙江
每日一题
A29860号题解:
t题目:
Description of the question
Given three positive integers representing the lengths of three line segments, determine whether these three segments form a triangle. If a triangle can be formed, output "yes"; otherwise, output "no".
Input format
The input consists of one line containing three positive integers, each representing the length of three line segments, separated by a space.
Output format
If a triangle can be formed, output "yes"; otherwise, output "no".
t解析:
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
// 找出最大值
int maxi = a;
if (b > maxi) maxi = b;
if (c > maxi) maxi = c;
// 三条边之和减去最大值 = 较小两条边之和
int sum = a + b + c - maxi;
if (sum > maxi) {
cout << "yes" << '\n';
} else {
cout << "no" << '\n';
}
return 0;
}
记得三连哦!!!
全部评论 1
有帮助吗?记得三连哦!
2026-09-27 来自 浙江
1


















有帮助,赞一个