URI Online Judge Solution 1045 Triangle Types Solution in C, C++, Java, Python and C#
URI Online Judge Solution 1045 Triangle Types | Beginner
URI Problem Link – https://www.urionlinejudge.com.br/judge/en/problems/view/1045
Problem Name: 1045 Triangle Types
Problem Number : URI – 1045 Triangle Types
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)
URI 1045 Triangle Types Code in C / URI 1045 solution in C:
#include <stdio.h>
int main()
{
double a, b, c, temp;
scanf("%lf %lf %lf", &a, &b, &c);
if (a < b)
{
temp = a;
a = b;
b = temp;
}
if (b < c)
{
temp = b;
b = c;
c = temp;
}
if (a < b)
{
temp = a;
a = b;
b = temp;
}
if (a >= b + c)
{
printf("NAO FORMA TRIANGULOn");
}
else if (a * a == b * b + c * c)
{
printf("TRIANGULO RETANGULOn");
}
else if (a * a > b * b + c * c)
{
printf("TRIANGULO OBTUSANGULOn");
}
else if (a * a < b * b + c * c)
{
printf("TRIANGULO ACUTANGULOn");
}
if (a == b && b == c)
{
printf("TRIANGULO EQUILATEROn");
}
else if (a == b || b == c)
{
printf("TRIANGULO ISOSCELESn");
}
return 0;
}
URI 1045 Triangle Types Code in C++ / URI 1045 solution in CPP:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
float x;
vector<float> v;
for (int i = 0; i < 3; ++i)
{
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.begin() + 3);
float a, b, c;
c = v[0];
b = v[1];
a = v[2];
if(a >= (b + c)){
cout << "NAO FORMA TRIANGULO" << endl;
}else{
if(a*a == (b*b + c*c)){
cout << "TRIANGULO RETANGULO" << endl;
}else if(a*a > (b*b + c*c)){
cout << "TRIANGULO OBTUSANGULO" << endl;
}else{
cout << "TRIANGULO ACUTANGULO" << endl;
}
if(a == b && b == c){
cout << "TRIANGULO EQUILATERO" << endl;
}
if((a == b && a != c) || (b == c && b != a) || (c == a && c != b)){
cout << "TRIANGULO ISOSCELES" << endl;
}
}
return 0;
}
URI 1045 Triangle Types Code in java/ URI 1045 solution in Java:
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
double A, B, C;
Scanner input =new Scanner(System.in);
A = input.nextDouble();
B = input.nextDouble();
C = input.nextDouble();
double tempA = Math.max(A, Math.max(B, C));
double tempB = 0;
double tempC = 0;
if (tempA == A) {
tempB =Math.max(B, C);
tempC =Math.min(B, C);
}
if (tempA == B) {
tempB =Math.max(A, C);
tempC =Math.min(A, C);
}
if (tempA == C) {
tempB =Math.max(B, A);
tempC =Math.min(B, A);
}
//------------------------------
if (tempA >= (tempB + tempC)) {
System.out.print("NAO FORMA TRIANGULOn");
}else if (tempA*tempA > ((tempB*tempB)+(tempC*tempC))) {
System.out.print("TRIANGULO OBTUSANGULOn");
}
if (tempA*tempA == ((tempB*tempB)+(tempC*tempC))) {
System.out.print("TRIANGULO RETANGULOn");
}
if (tempA*tempA < ((tempB*tempB)+(tempC*tempC))) {
System.out.print("TRIANGULO ACUTANGULOn");
}
if ((tempA == tempB) &&(tempA == tempC)) {
System.out.print("TRIANGULO EQUILATEROn");
}
if (((tempA == tempB) &&(tempA != tempC)) || ((tempA == tempC) &&(tempA != tempB)) || ((tempB == tempC) &&(tempB != tempA)) ) {
System.out.print("TRIANGULO ISOSCELESn");
}
}
}
URI 1045 Triangle Types Code in Python / URI 1045 solution in Python:
URI Solution 1045 Triangle Types Code / URI 1045 solution in C# (C Sharp):
Demonstration:
Just implement this in coding. Since having any problem just put a comment below. Thanks
Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI Triangle Types code in C, URI 1045 Triangle Types code in C++, URI Triangle Types solution in C, URI solution, URI 1045 solution in C,URI 1045 solution in C++-CPP, URI 1045 Triangle Types solution in C# (C sharp),URI 1045 solution in Java,URI 1045 Triangle Types solution in Python,