Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created October 16, 2019 16:24
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/ee30e96056d6a5bfe1cb29e0b1a7fcff to your computer and use it in GitHub Desktop.
Save parzibyte/ee30e96056d6a5bfe1cb29e0b1a7fcff to your computer and use it in GitHub Desktop.
/*
Esta función regresa el índice del elemento buscado
dentro del arreglo; si no lo encuentra regresa -1
Recibe el arreglo, la búsqueda y la longitud del arreglo,
recuerda que la longitud se debe pasar porque al pasar por
referencia no se puede obtener la longitud
*/
int buscarEnArreglo(const int arreglo[], int busqueda, int longitud) {
for (int x = 0; x < longitud; x++) {
if (arreglo[x] == busqueda) return x;
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment