【ACM】杭电OJ 2039

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/CSDN___CSDN/article/details/84344511

先让啊、三边边长a,b,c按从小到大顺序排列,然后再用两边之和大于第三边,两边之差小于第三边来判断

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <set>
#include <algorithm>
using namespace std;
int main ()
{
	int n;
	double a,b,c,minn,t;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%lf%lf%lf",&a,&b,&c);
		if(a>b)
		{t=a;a=b;b=t;}
		if(a>c)
		{t=a;a=c;c=t;}
		if(b>c)
		{t=b;b=c;c=t;}
		if(a+b>c && c-b<a)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/CSDN___CSDN/article/details/84344511