Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 14, 2021 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/1bcdbb96c08c354f0f48a93b5fa5c4ac to your computer and use it in GitHub Desktop.
Save parzibyte/1bcdbb96c08c354f0f48a93b5fa5c4ac to your computer and use it in GitHub Desktop.
"""
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