-
-
Save parzibyte/1bcdbb96c08c354f0f48a93b5fa5c4ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
https://parzibyte.me/blog | |
""" | |
def mayor_de_arreglo(arreglo): | |
# Supongamos que el mayor es el primero solo para tener un valor para inicializar | |
mayor = arreglo[0] | |
# Recorrer y buscar | |
for elemento in arreglo: | |
if elemento > mayor: | |
mayor = elemento | |
return mayor | |
def menor_de_arreglo(arreglo): | |
menor = arreglo[0] | |
for elemento in arreglo: | |
if elemento < menor: | |
menor = elemento | |
return menor | |
# Probar | |
arreglo = [0, -1, 4, 6000, 1, 2, 1400, -10, 90, 13, 7, 12, 500, 16] | |
mayor = mayor_de_arreglo(arreglo) | |
menor = menor_de_arreglo(arreglo) | |
print(f"Del arreglo {arreglo} el mayor es {mayor} y el menor es {menor}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment