ALGORITMO PARA SABER SI SUS LADOS FORMAN UN TRIÁNGULO

Categoría de Estructura Condicional Múltiple


Algoritmo que muestra si los lados forman un triángulo en PSeInt

💻 Hacer un algoritmo que muestre el área del triángulo. Utilice el teorema de Herón para comprobar si sus lados forman un triángulo.


✅ OTROS EJERCICIOS USANDO TRIÁNGULOS :

🔹 CALCULAR EL ÁREA Y PERÍMETRO DEL TRIÁNGULO
🔹 MOSTRAR SI LOS LADOS FORMAN UN TRIÁNGULO
🔹 MUESTRA LA BASE Y ALTURA DE UN TRIÁNGULO
🔹 MUESTRA GRÁFICA DE NÚMEROS EN FORMA DE TRIÁNGULO
🔹 MUESTRA EL TRIÁNGULO DE PASCAL
🔹 DIBUJAR UN TRIÁNGULO EQUILÁTERO DE ASTERÍSCOS


Algoritmo en pseint que muestre si los lados ingresados forman un triángulo PSeInt Estricto : DESCARGA EL CÓDIGO

algoritmo forman un triángulo

Algoritmo en pseint - short youtube
Algoritmo programacion_work
    Definir L1, L2, L3 como Entero;
    Definir Area, Semi como Real;
    Escribir "TEOREMA DE HERÓN - MUESTRA SI LOS LADOS FORMAN UN TRIÁNGULO.";
    Escribir " ";
    Escribir Sin Saltar "Ingrese Lado 01 : ";
    Leer L1;
    Escribir Sin Saltar "Ingrese Lado 02 : ";
    Leer L2;
    Escribir Sin Saltar "Ingrese Lado 03 : ";
    Leer L3;
    Escribir " ";	
    Semi <- (L1 + L2 + L3) / 2;
    Area <- RAIZ(Semi * (Semi - L1) * (Semi - L2) * (Semi - L3));	
    Si (Area <= 0) Entonces
        Escribir "LOS LADOS INSERTADOS NO FORMAN UN TRIÁNGULO";
    Sino
        Escribir "EL ÁREA DEL TRIÁNGULO ES : ", Area;
    FinSi	
FinAlgoritmo
lados ingresados forman un triángulo en pseint

código en python que muestra si los lados ingresados forman un triángulo Python :

print("03. USAR TEOREMA DE HERÓN - PARA SABER SI ES UN TRIÁNGULO.")
from math import sqrt
l1 = int(input("Ingrese Lado 01 : "))
l2 = int(input("Ingrese Lado 02 : "))
l3 = int(input("Ingrese Lado 03 : "))
print()
if (l1+l2)>l3 and (l2+l3)>l1 and (l3+l1)>l2:
    print("LOS LADOS INSERTADOS FORMAN UN TRIÁNGULO")
    semi = (l1+l2+l3)/2
    print("SEMIPERÍMETRO : ",semi)
    area = (semi*(semi-l1)*(semi-l2)*(semi-l3))
    area = sqrt(area)
    print("ÁREA : {:.2f}".format(area))
else:
    print("LOS LADOS NO PERTENECEN A UN TRIÁNGULO")

código en Lenguaje C que los lados forman un triángulo LENGUAJE C :

#include<stdio.h>
#include<math.h>
int main() {
    float area, semi, l1, l2, l3;
    printf("03. MOSTRAR EL AREA DE UN TRIANGULO - TEOREMA DE HERON.\n\n");    
    printf("Ingrese Lado 01 : ");
    scanf("%f",&l1);
    printf("Ingrese Lado 02 : ");
    scanf("%f",&l2);    
    printf("Ingrese Lado 02 : ");
    scanf("%f",&l3);
    if ((l1+l2)>l3 && (l2+l3)>l1 && (l3+l1)>l2) {
        printf("\nLOS LADOS INSERTADOS FORMAN UN TRIANGULO\n");
        semi = (l1+l2+l3)/2;
        printf("SEMIPERIMETRO : %f\n", semi);
        area = (semi*(semi-l1)*(semi-l2)*(semi-l3));
        area = sqrtf(area);
        printf("AREA : %f\n", area);
    } else {
        printf("\nLOS LADOS NO PERTENECEN A UN TRIANGULO\n");
    }
    return 0;
}

código en Dev C++ que indique si los lados ingresados son de un triángulo Dev C++ :

#include<iostream>
#include<math.h>
using namespace std;
int main() {
    float area, semi, l1, l2, l3;
    cout << "03. MOSTRAR EL AREA DE UN TRIANGULO - TEOREMA DE HERON.\n\n";          
    cout << "Ingrese Lado 01 : ";
    cin >> l1;
    cout << "Ingrese Lado 02 : ";
    cin >> l2;
    cout << "Ingrese Lado 03 : ";
    cin >> l3;
    cout << endl;
    if ((l1+l2)>l3 && (l2+l3)>l1 && (l3+l1)>l2) {
        cout << "LOS LADOS INSERTADOS FORMAN UN TRIANGULO" << endl;
        semi = (l1+l2+l3)/2;
        cout << "SEMIPERIMETRO : " << semi << endl;
        area = (semi*(semi-l1)*(semi-l2)*(semi-l3));
        area = sqrtf(area);
        cout << "AREA : " << area << endl;
    } else {
        cout << "LOS LADOS NO PERTENECEN A UN TRIANGULO" << endl;
    }
    return 0;
}

código en C# que verifica si los lados ingresados forman un triángulo C# :

using System;
using System.Collections.Generic;
using System.Text;
namespace programacion_work
{
    class conocer_si_es_triangulo
    {
        static void Main(string[] args)
        {
            double area, semi, l1, l2, l3;
            Console.WriteLine("03. MOSTRAR EL AREA DE UN TRIANGULO - TEOREMA DE HERON.\n");
            Console.Write("Ingrese Lado 01 : ");
            l1 = int.Parse(Console.ReadLine());
            Console.Write("Ingrese Lado 02 : ");
            l2 = int.Parse(Console.ReadLine());
            Console.Write("Ingrese Lado 03 : ");
            l3 = int.Parse(Console.ReadLine());
            if ((l1 + l2) > l3 && (l2 + l3) > l1 && (l3 + l1) > l2)
            {
                Console.WriteLine("\nLOS LADOS INSERTADOS FORMAN UN TRIANGULO");
                semi = (l1 + l2 + l3) / 2;
                Console.WriteLine("SEMIPERIMETRO : " + semi);
                area = (semi * (semi - l1) * (semi - l2) * (semi - l3));
                area = Math.Sqrt(area);
                Console.WriteLine("AREA : " + area);
            }
            else
            {
                Console.WriteLine("\nLOS LADOS NO PERTENECEN A UN TRIANGULO");
            }
            Console.ReadLine();
        }
    }
}

Programar en Java NetBeans si los lados ingresados forman un triángulo Java NetBeans :

package programacion_work;
import java.util.Scanner;
public class si_es_triangulo {
    public static void main(String[] args) {
        Scanner ingreso=new Scanner(System.in);  
        int L1, L2, L3;
        double AREA, SEMI;
        System.out.print("03. MUESTRA ÁREA DEL TRIÁNGULO USANDO TEOREMA DE HERÓN.\n\n");
        System.out.print("Ingrese Lado 01 : ");
        L1 = Integer.parseInt(ingreso.next());
        System.out.print("Ingrese Lado 02 : ");
        L2 = Integer.parseInt(ingreso.next());
        System.out.print("Ingrese Lado 03 : ");
        L3 = Integer.parseInt(ingreso.next());
        if((L1 + L2) > L3 && (L2 + L3) > L1 && (L3 + L1)> L2){
            System.out.println("\nLOS LADOS INSERTADOS FORMAN UN TRIÁNGULO");
            SEMI = (double)(L1 + L2 + L3) / 2;
            System.out.println("SEMIPERIMETRO : " + SEMI);
            AREA = (double)(SEMI * (SEMI - L1) * (SEMI - L2) * (SEMI - L3));
            AREA = (double) Math.sqrt(AREA);
            System.out.println("ÁREA : " + AREA);
        }else{
            System.out.println("LOS LADOS NO PERTENECEN A UN TRIÁNGULO");
        }
    }  
}

mostrar si los lados ingresados forman un triángulo en visual basic .net consola Visual Basic .NET - Consola :

Imports System.Console
Imports System.Math
Module si_es_triangulo
    Dim L1, L2, L3, Area, Semi As Decimal
    Sub Main()
        WriteLine("03. CONOCER SI LOS LADOS FORMAN UN TRIÁNGULO.")
        WriteLine("")
        Write("Ingrese lado 1: ")
        L1 = ReadLine()
        Write("Ingrese lado 2: ")
        L2 = ReadLine()
        Write("Ingrese lado 3: ")
        L3 = ReadLine()
        WriteLine("")
        If ((L1 + L2) > L3 And (L2 + L3) > L1 And (L3 + L1) > L2) Then
            WriteLine("Los Lados Insertados Forman un Triángulo")
            Semi = (L1 + L2 + L3) / 2
            WriteLine("SEMIPERÍMETRO : " & Semi)
            Area = (Semi * (Semi - L1) * (Semi - L2) * (Semi - L3))
            Area = Sqrt(Area)
            WriteLine("El Área del Triángulo usando HERÓN: " & Area)
        Else
            WriteLine("Los Lados NO Pertenecen a un Triángulo")
        End If
        ReadLine()
    End Sub
End Module

ver si los lados forman un triángulo visual basic .net consola Visual Basic .NET - Formulario :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim L1, L2, L3, Area, Semi As Decimal
    L1 = Txt_Lado1.Text
    L2 = Txt_Lado2.Text
    L3 = Txt_Lado3.Text
    If ((L1 + L2) > L3 And (L2 + L3) > L1 And (L3 + L1) > L2) Then
        Semi = (L1 + L2 + L3) / 2
        Area = (Semi * (Semi - L1) * (Semi - L2) * (Semi - L3))
        Area = Math.Sqrt(Area)
        Lbl_msg1.Text = "Los Lados Insertados Forman un Triángulo"
        Lbl_msg2.Text = "SEMIPERÍMETRO : " & Math.Round(Semi, 2)
        Lbl_msg3.Text = "El Área del Triángulo usando HERÓN: " & Math.Round(Area, 2)
    Else
        Lbl_msg1.Text = "Los Lados NO Pertenecen a un Triángulo"
        Lbl_msg2.Text = ""
        Lbl_msg3.Text = ""
    End If
End Sub

indicar si los lados muestrán un triángulo en VBA Excel VBA :

Sub Triangulo()
    Dim L1, L2, L3 As Integer
    Dim Area, Semi As Double
    L1 = CInt(Range("C12").Value)
    L2 = CInt(Range("D12").Value)
    L3 = CInt(Range("E12").Value)
    If (L1 + L2) > L3 And (L2 + L3) > L1 And (L3 + L1) > L2 Then
        Semi = (L1 + L2 + L3) / 2
        Area = (Semi * (Semi - L1) * (Semi - L2) * (Semi - L3))
        Area = Sqr(Area)
        Range("G12").Value = "FORMAN UN TRIÁNGULO"
        Range("G13").Value = "SEMIPERÍMETRO : " & Semi
        Range("G14").Value = "ÁREA : " & Round(Area, 2)
    Else
        Range("G12").Value = "NO FORMA UN TRIÁNGULO"
        Range("G13").Value = ""
        Range("G14").Value = ""
    End If
End Sub

Programar si los lados ingresados forman un triángulo en excel Excel – InputBox :

Sub Triangulo2()
    Dim L1, L2, L3 As Integer
    Dim Area, Semi As Double
    L1 = CInt(InputBox("INGRESE LADO 01 "))
    L2 = CInt(InputBox("INGRESE LADO 02 "))
    L3 = CInt(InputBox("INGRESE LADO 03 "))
    If ((L1 + L2) > L3) And ((L2 + L3) > L1) And ((L3 + L1) > L2) Then
        Semi = (L1 + L2 + L3) / 2
        Area = (Semi * (Semi - L1) * (Semi - L2) * (Semi - L3))
        Area = Sqr(Area)
        MsgBox "FORMAN UN TRIÁNGULO" & vbNewLine & "SEMIPERÍMETRO : " & Semi & vbNewLine & "ÁREA : " & Round(Area, 2)
    Else
        MsgBox "LOS LADOS NO PERTENECEN A UN TRIÁNGULO"
    End If
End Sub

verificar si los lados ingresados forman un triángulo en excel VBA – Formulario [POO] :

Private Sub btn_calcular_Click()
    Dim L1, L2, L3 As Integer
    Dim Area, Semi As Double
    L1 = CInt(txt_num1.Text)
    L2 = CInt(txt_num2.Text)
    L3 = CInt(txt_num3.Text)
    If (L1 + L2) > L3 And (L2 + L3) > L1 And (L3 + L1) > L2 Then
        Semi = (L1 + L2 + L3) / 2
        Area = (Semi * (Semi - L1) * (Semi - L2) * (Semi - L3))
        Area = Sqr(Area)
        txt_result.Text = "LOS LADOS FORMAN UN TRIÁNGULO - SU ÁREA ES : " & Round(Area, 2)
    Else
        txt_result.Text = "LOS LADOS NO PERTENECEN A UN TRIÁNGULO"
    End If
End Sub



Facebook de www.programacion.work. Canal de Youtube de www.programacion.work. Twitter de www.programacion.work. TikTok de www.programacion.work.


Política de cookies

Política de Privacidad

Aviso Legal y Términos De Uso