CONTENIDO DE LA LECCIÓN 18
CONTENIDO DE LA LECCIÓN 18
CONTENIDO DE LA LECCIÓN 18
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
MIGUEL Á. TOLEDO MARTÍNEZ<br />
/* El siguiente programa: BUSLINEAL.CPP, ilustra el método de búsqueda lineal en un arreglo. */<br />
#include //Para cout y cin<br />
int busquedaLineal(const int[], int, int);<br />
void main(void)<br />
{<br />
const int TAMANO_ARREGLO = 100;<br />
int a[TAMANO_ARREGLO], claveBusqueda, elemento;<br />
for(int x = 0; x < TAMANO_ARREGLO; x++) //Crea algunos datos<br />
a[x] = 2 * x;<br />
cout > claveBusqueda;<br />
elemento = busquedaLineal(a, claveBusqueda, TAMANO_ARREGLO);<br />
if(elemento != -1)<br />
cout