三角形(惯性思维)



Problem Description
给定三条边,请你判断一下能不能组成一个三角形。
 
Input
输入数据第一行包含一个数M,接下有M行,每行一个实例,包含三个正数A,B,C。其中A,B,C <1000;
 
Output
对于每个测试实例,如果三条边长A,B,C能组成三角形的话,输出YES,否则NO。
 
Sample Input
2 1 2 3 2 2 2
 
Sample Output
NO
YES
               一看这道题目,这么简单,结果wa了好几次。。。惯性思维了,没考虑到边长不只是整型。
 1 #include<iostream>
 2 #include<iomanip>
 3 //#include<bits/stdc++.h>
 4 #include<cstdio>
 5 #include<algorithm>
 6 #include<cmath>
 7 #define PI  3.14159265358979
 8 #define LL long long
 9 #define INF  10000001000
10 #define  eps   0.00000001
11 using namespace std;
12 int main()
13 {
14     LL T;
15    double a,b,c;
16     cin>>T;
17     while(T--)
18     {
19         cin>>a>>b>>c;
20         if(a+b>c&&a+c>b&&b+c>a) puts("YES");
21         else puts("NO");
22 
23     }
24 }
View Code

猜你喜欢

转载自www.cnblogs.com/Auroras/p/10802477.html