What’s wrong in this code? :-/
Your code is logically correct. I think WA is because of precision of sqrt function in math.h
Values of side1,side2 and side3 are actually approximated values and when you square them, there might be cases when your inner if condition gives wrong results.
Instead of returning absolute distance, you can return the square of distance of any two points from your dist() function. Now there will be no problem of precision and you can simply check if side1+side2=side3.
(side1, side2, side3 are squares of actual size) and similarly for other two cases.
Take a look at your slightly modified code: Link
dont use sqrt() function just use square of sides…for comparisions…dnt need to calculate square every tym sqareOfDist[(x1,y1),(x2,y2)]=(x1-x2)(x1-x2)+(y1-y2)(y1-y2);
choose order of a<=b<=c
if(cc == aa + b*b) continue;