Beecrowd-1043 Triangle-solution ||Beecrowd 1043 solution
Triangle
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 three 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 |
Beecrowd -1043 Triangle Solution in C
#include<stdio.h>
int main() {
float a,b,c,area;
scanf("%f%f%f",&a,&b,&c);
if(a+b>c&&a+c>b&&b+c>a){
printf("Perimetro = %.1f\n",a+b+c);
}
else{
area =.5*(a+b)*c;
printf("Area = %.1f\n",area);
}
return 0;
}
Beecrowd 1043 solution in C++
#include <iostream>
using namespace std;
int main() {
float a, b, c, area;
cin >> a >> b >> c;
if(a + b > c && a + c > b && b + c > a){
cout << "Perimetro = " << a + b + c << endl;
}
else{
area = 0.5 * (a + b) * c;
cout << "Area = " << area << endl;
}
return 0;
}





0 thoughts on “Beecrowd 1043 solution in C ,C++ || Uri 1043”