Lee tres números y imprime de mayor y viceversa - PSeInt.Site
DESARROLLAMOS TUS ALGORITMOS (+51) 988411115
09. Programa un algoritmo que lea tres números y los imprima de mayor a menor y de menor a mayor.
¿EN QUE PROGRAMA QUIERES VER EL CÓDIGO? :
Curso de autocad, google colaboratory, curso de C, certificacion google, curso marketing digital, cisco python, páginas Web.
ANÁLISIS :
Lo primero seria ordenar por descarte:
Por ejemplo: Si N1 > N2 y N1 > N3, sabemos que N1 es el mayor, por lo tanto faltaría preguntar si N2 > N3, si se da el caso que N2 es mayor que N3 fácil mente se sabe que : N1 es mayor, N2 es intermedio y N3 es el menor y se imprimen en ese orden.
Diagrama de flujo(DFD) para mostrar de mayor a menor y de menor a mayor:
PSeInt - FLEXIBLE DESCARGA CÓDIGO
Algoritmo Condicional09 Escribir "Ingrese Número 01 : " Leer N1 Escribir "Ingrese Número 02 : " Leer N2 Escribir "Ingrese Número 03 : " Leer N3 Si (N1 > N2) Y (N1 > N3) Entonces P = N1 Si N2 > N3 Entonces S = N2 T = N3 SiNo S = N3 T = N2 Fin Si SiNo Si N2 > N3 Entonces P = N2 Si N1 > N3 Entonces S = N1 T = N3 SiNo S = N3 T = N1 Fin Si SiNo P = N3 Si N1 > N2 Entonces S = N1 T = N2 SiNo S = N2 T = N1 Fin Si Fin Si Fin Si Escribir "Descendente : ", P " - " S " - " T Escribir "Ascendente : ", T " - " S " - " PFinAlgoritmo PSeInt - ESTRICTO DESCARGA CÓDIGO
Algoritmo Condicional09 Definir N1, N2, N3, S, T, P como Entero; Escribir "Ingrese Número 01 : "; Leer N1; Escribir "Ingrese Número 02 : "; Leer N2; Escribir "Ingrese Número 03 : "; Leer N3; Si (N1 > N2) Y (N1 > N3) Entonces P N3 Entonces S n3)) { p = n1; if (n2>n3) { s = n2; t = n3; } else { s = n3; t = n2; } } else { if (n2>n3) { p = n2; if (n1>n3) { s = n1; t = n3; } else { s = n3; t = n1; } } else { p = n3; if (n1>n2) { s = n1; t = n2; } else { s = n2; t = n1; } } } cout xn3){ s = xn2; t = xn3; }else{ s = xn3; t = xn2; } }else{ if(xn2 > xn3){ p = xn2; if(xn1 > xn3){ s = xn1; t = xn3; }else{ s = xn3; t = xn1; } }else{ p = xn3; if(xn1 > xn2){ s = xn1; t = xn2; }else{ s = xn2; t = xn1; } } } document.getElementById('result1').value=p + " , " + s + " , " + t; document.getElementById('result2').value=t + " , " + s + " , " + p; }]]> INGRESE NUMERO 01 : INGRESE NUMERO 02 :
INGRESE NUMERO 03 :
DESCENDENTE:
ASCENDENTE: