Friday, August 12, 2016

UVA 11936 - The Lazy Lumberjacks solution

problem link-click here

Use your brain and find the statement if you can find which is

"The sum of the lengths of any two sides of a triangle must be greater than the third side".

if this is not true then you do not have a triangle...........

for more information visit Triangle_inequality/Wikipedia

here we go,

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;

    scanf("%d",&t);

    while(t--)
    {
        int a[10];

        scanf("%d%d%d",&a[0],&a[1],&a[2]);
        sort(a,a+3);

        if(a[0]+a[1]>a[2])
        {
            printf("OK\n");
        }
        else
        {
            printf("Wrong!!\n");
        }

    }

    return 0;
}

No comments:

Post a Comment