ALGORITMO QUE MUESTRE EL NÚMERO INTERMEDIO

Categoría de Estructura Condicional Simple


CÓDIGO QUE MUESTRA EL NÚMERO INTERMEDIO.

💻 Hacer un programa que muestre el número intermedio de tres números enteros ingresados.


Análisis :

Hay muchas formas de desarrollar este ejercicio, en este caso lo que haremos será comparar cada número hasta obtener el intermedio:

Aplicaremos la lógica del primer diagrama de flujo:
Tomamos como referencia: N1 = 5, N2 = 3, N3=9; a simple vista el número intermedio sería 5.

Paso 1: Si ¿N1(5) es mayor que N2(3)?; “entonces MEDIO = N1 (5) y XTEM = N2(3)”; No aplicamos el caso contrario porque no se cumple.
Paso 2: Si ¿MEDIO(5) es mayor que N3(9)?, “NO SE CUMPLE”.
Paso 3: Si ¿MEDIO(5) es mayor que XTEM(2)?, “NO SE CUMPLE”.
Paso 4: Por lo tanto mostramos por pantalla el Número intermedio: MEDIO(5).

La base está en la primera consulta, dónde se toma el valor intermedio como referencia, para final mente compararlo con el último valor.


ANÁLISIS DEL CÓDIGO

VARIABLES ENTRADA :
N1 = Guarda primer valor.
N2 = Guarda segundo valor.
N3 = Guarda tercer valor.
MEDIO = Guardar el valor medio encontrado.
XTEM = Variable temporal.

INGRESO : Se ingresan los 3 números (N1, N2, N3)
PROCESO : Compara cada número para obtener el valor medio.
SALIDA : Muestra el valor intermedio (Variable MEDIO).


Algoritmo en pseint que muestre el número intermedio PSeInt Estricto : DESCARGA EL CÓDIGO

algoritmo que calcule el IGV

Algoritmo en pseint - short youtube
Algoritmo programacion_work 
    Definir N1, N2, N3, MEDIO, XTEM como Entero;
    Escribir "INGRESE 3 NÚMEROS Y MUESTRE EL VALOR INTERMEDIO.";
    Escribir " ";
    Escribir Sin Saltar "Ingrese Número 01 : ";
    Leer N1;
    Escribir Sin Saltar "Ingrese Número 02 : ";
    Leer N2;
    Escribir Sin Saltar "Ingrese Número 03 : ";
    Leer N3;
    Si N1 > N2 Entonces
        MEDIO <- N1;
        XTEM <- N2;
    SiNo
        MEDIO <- N2;
        XTEM <- N1;
    FinSi
    Si MEDIO > N3 Entonces
        MEDIO <- N3;
    FinSi
    Si MEDIO < XTEM Entonces
        MEDIO <- XTEM;
    FinSi
    Escribir " ";
    Escribir "El número Medio es : ", MEDIO;
FinAlgoritmo
 muestre el número intermedio en pseint

código en python que muestra el número intermedio Python :

print("MUESTRA EL NÚMERO INTERMEDIO.")
n1 = int(input("Ingrese Número 01 : "))
n2 = int(input("Ingrese Número 02 : "))
n3 = int(input("Ingrese Número 03 : "))
if n1>n2:
    medio = n1
    xtem = n2
else:
    medio = n2
    xtem = n1
if medio > n3:
    medio = n3
if medio < xtem :
    medio = xtem
print("El número Medio es : ",medio)

código en Lenguaje C que muestra el valor intermedio Lenguaje C :

#include<stdio.h>
int main() {
    int medio, n1, n2, n3, xtem;
    printf("MOSTRAR EL NUMERO INTERMEDIO.\n\n");           
    printf("Ingrese Numero 01 : ");
    scanf("%i",&n1);
    printf("Ingrese Numero 02 : ");
    scanf("%i",&n2);
    printf("Ingrese Numero 03 : ");
    scanf("%i",&n3);
    if (n1>n2) {
        medio = n1;
        xtem = n2;
    } else {
        medio = n2;
        xtem = n1;
    }
    if (medio > n3) {
        medio = n3;
    }
    if (medio < xtem) {
        medio = xtem;
    }
    printf("\nEl mumero medio es : %i\n",medio);
    return 0;
}

código en Dev C++ muestra el valor intermedio de 3 números Dev C++ :

#include<iostream>
using namespace std;
int main() {
    int medio, n1, n2, n3, xtem;
    cout << "15. MOSTRAR EL NUMERO INTERMEDIO.\n\n";        
    cout << "Ingrese Numero 01 : ";
    cin << n1;
    cout << "Ingrese Numero 02 : ";
    cin << n2;
    cout << "Ingrese Numero 03 : ";
    cin << n3;
    if (n1>n2) {
        medio = n1;
        xtem = n2;
    } else {
        medio = n2;
        xtem = n1;
    }
    if (medio > n3) {
        medio = n3;
    }
    if (medio < xtem) {
        medio = xtem;
    }
    cout << endl << "El mumero medio es : " << medio << endl;
    return 0;
}

código en C# que muestra el número intermedio C# :

using System;
using System.Collections.Generic;
using System.Text;
namespace programacion_work
{
    class numero_medio
    {
        static void Main(string[] args)
        {
            int medio, n1, n2, n3, xtem;
            Console.WriteLine("MOSTRAR EL NUMERO INTERMEDIO.\n");
            Console.Write("Ingrese Numero 01 : ");
            n1 = int.Parse(Console.ReadLine());
            Console.Write("Ingrese Numero 02 : ");
            n2 = int.Parse(Console.ReadLine());
            Console.Write("Ingrese Numero 03 : ");
            n3 = int.Parse(Console.ReadLine());
            if (n1 > n2)
            {
                medio = n1;
                xtem = n2;
            }
            else
            {
                medio = n2;
                xtem = n1;
            }
            if (medio > n3)
            {
                medio = n3;
            }
            if (medio < xtem)
            {
                medio = xtem;
            }
            Console.WriteLine("\nEl mumero medio es : " + medio);
            Console.ReadLine();
        }
    }
}

Programar en Java NetBeans que vea el número intermedio Java NetBeans :

package programacion_work;
import java.util.Scanner;
public class num_intermedio {
    public static void main(String[] args) {
        Scanner ingreso=new Scanner(System.in);  
        int N1, N2, N3, MEDIO, XTEM;
        System.out.print("INGRESA 3 NÚMEROS Y MUESTRA EL VALOR INTERMEDIO.\n\n");          
        System.out.print("Ingrese Nro 01 : ");
        N1 = Integer.parseInt(ingreso.next());
        System.out.print("Ingrese Nro 02 : ");
        N2 = Integer.parseInt(ingreso.next());
        System.out.print("Ingrese Nro 03 : ");
        N3 = Integer.parseInt(ingreso.next());
        if(N1 > N2){
            MEDIO = N1;
            XTEM = N2;
        }else{
            MEDIO = N2;
            XTEM = N1;
        }
        if(MEDIO > N3){
            MEDIO = N3;
        }
        if(MEDIO < XTEM){
            MEDIO = XTEM;
        }
        System.out.println("\nEL NÚMERO MEDIO ES : " + MEDIO);
    }   
}

muestra el número intermedio en Java NetBeans Java NetBeans - FORMULARIOS [POO]:

private void jBtn_CalcularActionPerformed(java.awt.event.ActionEvent evt) {                                              
    int N1, N2, N3, MEDIO, XTEM;
    N1 = Integer.parseInt(jTxt_Nro1.getText());
    N2 = Integer.parseInt(jTxt_Nro2.getText());
    N3 = Integer.parseInt(jTxt_Nro3.getText());
    if(N1 > N2){
        MEDIO = N1;
        XTEM = N2;
    }else{
        MEDIO = N2;
        XTEM = N1;
    }
    if(MEDIO > N3){
        MEDIO = N3;
    }
    if(MEDIO < XTEM){
        MEDIO = XTEM;
    }
    JLbl_Msg.setText("EL NÚMERO MEDIO ES : " + MEDIO); 
} 

Mostrar el número intermedio en basic Visual Basic .NET Console:

Imports System.Console
Module numero_medio
    Dim N1, N2, N3, Medio, XTem As Integer
    Sub Main()
        WriteLine("15. MOSTRAR EL NÚMERO MEDIO DE 3 NÚMEROS INGRESADOS.")
        WriteLine("")
        Write("Igrese Número 1 : ")
        N1 = ReadLine()
        Write("Igrese Número 2 : ")
        N2 = ReadLine()
        Write("Igrese Número 3 : ")
        N3 = ReadLine()
        WriteLine("")
        If (N1 > N2) Then
            Medio = N1
            XTem = N2
        Else
            Medio = N2
            XTem = N1
        End If
        If (Medio > N3) Then
            Medio = N3
        End If
        If (Medio < XTem) Then
            Medio = XTem
        End If
        WriteLine("El Número Medio es : " & Medio)
        ReadLine()
    End Sub
End Module

Calcular el número intermedio en Visual basic Visual Basic .NET Formularios :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim N1, N2, N3, Medio, XTem As Integer
    N1 = Txt_Num1.Text
    N2 = Txt_Num2.Text
    N3 = Txt_Num3.Text
    If (N1 > N2) Then
        Medio = N1
        XTem = N2
    Else
        Medio = N2
        XTem = N1
    End If
    If (Medio > N3) Then
        Medio = N3
    End If
    If (Medio < XTem) Then
        Medio = XTem
    End If
    Lbl_Msg.Text = "El Número medio es : " & Medio
End Sub

Mostrar el valor medio en VBA Excel VBA :

Sub Medio()
    Dim N1, N2, N3, Medio, XTEM As Integer
    N1 = CInt(Range("C12").Value)
    N2 = CInt(Range("D12").Value)
    N3 = CInt(Range("E12").Value)
    If (N1 > N2) Then
        Medio = N1
        XTEM = N2
    Else
        Medio = N2
        XTEM = N1
    End If
    If (Medio > N3) Then
        Medio = N3
    End If
    If (Medio < XTEM) Then
        Medio = XTEM
    End If
    Range("G12").Value = Medio
End Sub

Programar el número intermedio en excel Excel – InputBox :

Sub Medio2()
    Dim N1, N2, N3, Medio, XTEM As Integer
    N1 = CInt(InputBox("INGRESE NÚMERO 1 "))
    N2 = CInt(InputBox("INGRESE NÚMERO 2 "))
    N3 = CInt(InputBox("INGRESE NÚMERO 3 "))
    If (N1 > N2) Then
        Medio = N1
        XTEM = N2
    Else
        Medio = N2
        XTEM = N1
    End If
    If (Medio > N3) Then
        Medio = N3
    End If
    If (Medio < XTEM) Then
        Medio = XTEM
    End If
    MsgBox "NÚMERO MEDIO : " & Medio
End Sub

muestra el número intermedio en excel VBA – Formulario [POO] :

Private Sub btn_calcular_Click()
    Dim N1, N2, N3, Medio, XTEM As Integer
    N1 = CDbl(txt_num1.Text)
    N2 = CDbl(txt_num2.Text)
    N3 = CDbl(txt_num3.Text)
    If (N1 > N2) Then
        Medio = N1
        XTEM = N2
    Else
        Medio = N2
        XTEM = N1
    End If
    If (Medio > N3) Then
        Medio = N3
    End If
    If (Medio < XTEM) Then
        Medio = XTEM
    End If
    txt_result.Text = Medio
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