Click Here to see the problem detail.

Solution

Algorithm:

step1:  Find out the largest arm of the triangle.

Step2: square of largest arm = sum of square of others two arms. If this condition is true then the triangle will be right otherwise wrong.

Source Code
#include<stdio.h>
 
int main()
{
    int sides[3],temp,i;
    while(1)
    {
        scanf("%d%d%d",&sides[0],&sides[1],&sides[2]);
        if(sides[0]==0 && sides[1]==0 && sides[2]==0)
            break;
        int flag=1;
        int j=1;
        while(flag)
        {
            flag=0;
            for(i=0; i<3-j; i++)
            {
                if(sides[i]<sides[i+1])
                {
                    temp=sides[i];
                    sides[i]=sides[i+1];
                    sides[i+1]=temp;
                    flag=1;
                }
            }
        }
        if(sides[0]*sides[0]== (sides[1]*sides[1]+sides[2]*sides[2]))
            printf("right\n");
        else
            printf("wrong\n");
    }
   return 0;
}

 


Next Previous