Beecrowd 1045 Triangle Types solution

Question

BEE 1045 – Triangle Types Solution in C

BEE 1045 – Triangle Types Solution in C++

#include <bits/stdc++.h>
using namespace std;


int main() {
    double a, b, c, temp, i, j;
    cin >> a >> b >> c;

    if (a < b) {
        temp = a;
        a = b;
        b = temp;
    }
    if (a < c) {
        temp = a;
        a = c;//Beecrowd 1045 Triangle Types solution 
        c = temp;
    }
    if (b < c) {
        temp = b;
        b = c;
        c = temp;
    }

    i = b * b + c * c;
    j = a * a;

    if (a >= b + c) {
cout << "NAO FORMA TRIANGULO" <<endl;
    } else {
        if (j == i) {
cout << "TRIANGULO RETANGULO" << endl;
        }
        if (j > i) {
cout << "TRIANGULO OBTUSANGULO" << endl;
        }
        if (j < i) {
cout << "TRIANGULO ACUTANGULO" <<endl;
        }
        if (a == b && b == c) {
cout << "TRIANGULO EQUILATERO" <<endl;
        } else if (a == b || b == c || c == a) {
cout << "TRIANGULO ISOSCELES" <<endl;
        }
    }

    return 0;
}

BEE 1045 – Triangle Types Solution in Python

def main():
    a, b, c = map(float, input().split())
    temp = 0
    i = 0
    j = 0

    if a < b:
        temp = a
        a = b
        b = temp
    if a < c:
        temp = a
        a = c
        c = temp
    if b < c:
        temp = b
        b = c
        c = temp

    i = b * b + c * c
    j = a * a

    if a >= b + c:
        print("NAO FORMA TRIANGULO")
    else:
        if j == i:
            print("TRIANGULO RETANGULO")
        if j > i:
            print("TRIANGULO OBTUSANGULO")
        if j < i:
            print("TRIANGULO ACUTANGULO")
        if a == b and b == c:
            print("TRIANGULO EQUILATERO")
        elif a == b or b == c or c == a:
            print("TRIANGULO ISOSCELES")

if __name__ == "__main__":
    main()

Next problem: Beecrowd 1046 solution || URI – BEECROWD – BEE Online Judge Solution  1046-Game Time

Leave a Comment