Sunday, February 1, 2015

Solution of 6A. Triangle (Codeforces)

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
#define pf printf
#define sc scanf
#define MAX 100
int arr[MAX];

int main()
{
    int i, j, k;
    int test, t;
    int arr[5];
    for(i=0; i<4; i++)
    {
        sc("%d",&arr[i]);
    }
    sort(arr, arr+4);
    if(arr[0]+arr[1]>arr[2] || arr[1]+arr[2]>arr[3])
    {
        printf("TRIANGLE\n");
    }
    else if(arr[0]+arr[1]==arr[2] || arr[1]+arr[2]==arr[3])
    {
        printf("SEGMENT\n");
    }
    else
    {
        printf("IMPOSSIBLE\n");
    }
}

No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...