URI - BEECROWD - BEE Online Judge Solution 1043 | Triangle - URI - BEECROWD - BEE 1043 Solution in C,C++,Python
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.
Input Sample | Output Sample |
6.0 4.0 2.0 | Area = 10.0 |
6.0 4.0 2.1 | Perimetro = 12.1 |
URI Online Judge Solution 1043 | Triangle - URI 1043 Solution in C,C++,Python:
What is the Perimeter of a Triangle?
The sum of the lengths of the sides is the perimeter of any polygon. In the case of a triangle,
Perimeter = Sum of the three sides
Perimeter of Triangle Formula:
The formula for the perimeter of a closed shape figure is usually equal to the length of the outer line of the figure. Therefore, in the case of a triangle, the perimeter will be the sum of all the three sides. If a triangle has three sides a, b and c, then,
Perimeter, P = a + b +c
A trapezium, also known as a trapezoid, is a quadrilateral in which a pair of sides are parallel, but the other pair of opposite sides are non-parallel. The area of a trapezium is computed with the following formula:
The parallel sides are called the bases of the trapezium. Let and be the lengths of these bases. The distance between the bases is called the height of the trapezium. Let be this height. Then this formula becomes:
#include<stdio.h>
int main()
{
float a,b,c,perimeter,area;
scanf("%f%f%f",&a,&b,&c);
if((a+b)>c&&(b+c)>a&&(c+a)>b){
perimeter=a+b+c;
printf("Perimetro = %.1f\n",perimeter);
}
else{
area=.5*(a+b)*c;
printf("Area = %.1f\n",area);
}
return 0;
}
0 Response to URI - BEECROWD - BEE 1043 | Triangle Solution in C,C++,Python | URI - BEECROWD - BEE 1043 Solution
Post a Comment