Question
Is Right Triangle DXC Automata Fix Questions AMCAT
Q) given three point find whether they forms a right angled triangle
or not.
int isRightTriangle(Point *p1,Point *p2,Point *p3)
{
//enter code
}
----------------------------------------
Solution
int isRightTriangle(Point *p1,Point *p2,Point *p3)
{
double d1,d2,d3,max,min,mid;
d1=point_calculateDistance(p1,p2);
d2=point_calculateDistance(p2,p3);
d3=point_calculateDistance(p1,p3);
max = (d1>d2)?(d1>d3?d1:d3):(d2>d3)?d2:d3;
min = (d1<d2)?(d1<d2?d1:d3):(d2<d3)?d2:d3;
mid = (d1+d2+d3)-(min+max);
if(max*max==min*min+mid*mid)
return 1;
else
return 0;
}