Created with <3 with dartpad.dev.
Created
November 7, 2023 02:00
-
-
Save leonus96/14442b026ae82ca05efae34b91db32f0 to your computer and use it in GitHub Desktop.
Ejercicio 3.2
This file contains hidden or 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
/// Escribe una función que tome una lista | |
/// de números y devuelva el número más | |
/// grande de la lista. Utiliza un bucle | |
/// for para encontrar el número máximo en | |
/// una lista. Imprime el resultado con | |
/// interpolación de cadenas. | |
void main() { | |
final List<int> enteros = [2, 43, 65645, 1, 4, 76, 7]; | |
print('El número más grande es: ${buscaGrande(enteros)}'); | |
} | |
int buscaGrande(List<int> numeros) { | |
int grande = 0; | |
for (int numero in numeros) { | |
if (numero > grande) { | |
grande = numero; | |
} | |
} | |
return grande; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment