Beecrowd-1043 Triangle-solution ||Beecrowd 1043 solution

Triangle

beecrowd | 1043

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 SampleOutput Sample
6.0 4.0 2.0Area = 10.0
6.0 4.0 2.1Perimetro = 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;
}

Next problem: Beecrowd -1044 Multiples Solution in C & C++

4 thoughts on “Beecrowd 1043 solution in C ,C++ || Uri 1043 || Free Code Center”

Leave a Comment