code not working here it works fine on codeblocks !!!!!!

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
int N,x1,x2,x3,y1,y2,y3,count=0;

scanf("%d",&N);

while(N--)
{
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    float L1,L2,L3,len;
    L1=sqrt(pow((fabs(x2-x1)),2) + pow((fabs(y2-y1)),2));
    L2=sqrt(pow((fabs(x3-x2)),2) + pow((fabs(y3-y2)),2));
    L3=sqrt(pow((fabs(x3-x1)),2) + pow((fabs(y3-y1)),2));
    if(L1>L2 && L1>L3)
    {
        len=sqrt(pow(L2,2)+pow(L3,2));

        if(len==L1)
            count++;
    }
    else if(L2>L1 && L2>L3)
    {
        len=sqrt(pow(L1,2)+pow(L3,2));

        if(len==L2)
            count++;
    }
    else if(L3>L2 && L3>L1)
    {
        len=sqrt(pow(L2,2)+pow(L1,2));

        if(len==L3)
            count++;
    }
} printf("%d\n",count);
return 0;

}

I was also getting a wrong answer here…
Apparenty, the precision in the float while finding sqrt makes the difference…
Do not take the sqrts and compare the squares of lengths directly… you’ll get AC :slight_smile:

thanks it worked after removing sqrt… :slight_smile:

1 Like