URI ONLINE JUDGE SOLUTION 1043 - Triangle

Problem

Read three point floating values (A, B and C) and verify if is possible to make a triangle with them. If it is possible, calculate the perimeter of the triangle and print the message:

Perimetro = XX.X

If it is not possible, calculate the area of the trapezium which basis A and B and C as height, and print the message:

Area = XX.X

Input

The input file has tree floating point numbers.

Output


Print the result with one digit after the decimal point.


sample input output

Solution
C programming source code for uri online judge beginner problem 1043 - Triangle:
#include<stdio.h>
int main() {     double a,b,c;
    scanf("%lf%lf%lf",&a,&b,&c);
    if(a+b>c && b+c>a && c+a>b)
        printf("Perimetro = %0.1lf\n",a+b+c);
    else
        printf("Area = %0.1lf\n",0.5*(a+b)*c);
    return 0;

}
How it works? This is the beginner level  problem of uri online judge.Here you would have to check if it is possible to make a triangle with three integer numbers. We know that the sum of two sides is greater than the third side of a triangle.Here we should check this exactly.Next the perimeter, It is the sum of all three sides. Hopefully you would understand the problem.Don't copy paste the code as same.Just try to understand it and then try yourself. It would be better for you.

Comments

Popular posts from this blog

URI ONLINE JUDGE SOLUTION 1021 - Banknotes and Coins

URI ONLINE JUDGE SOLUTION 1040 - Average 3

URI ONLINE JUDGE SOLUTION 1036 - Bhaskara's Formula