11.09.2018 Views

Aprender a desarrollar un sitio Web con PHP y MySQL

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

24/4/2014 ENI Training - Libro online<br />

$tabla1 = array();<br />

//F<strong>un</strong>ción para intercambiar el valor en <strong>un</strong>a tabla<br />

//La tabla pasa por referencia<br />

f<strong>un</strong>ction intercambiar(&$tabla, $i, $j)<br />

{<br />

$temporal = $tabla[$i];<br />

$tabla[$i] = $tabla[$j];<br />

$tabla[$j] = $temporal;<br />

}<br />

//rellenar <strong>un</strong>a tabla de 10 valores aleatorios comprendidos<br />

entre 1 y 100<br />

for ($i=1;$i0)<br />

{<br />

// búsqueda del mayor valor de la tabla<br />

$maximo = 1;<br />

for($i=1; $i$tabla1[$maximo]) {<br />

$maximo = $i;<br />

}<br />

}<br />

//intercambia el máximo <strong>con</strong> el último elemento<br />

intercambiar($tabla1, $maximo, $longitud);<br />

}<br />

// Procesar el resto de la tabla<br />

$longitud--;<br />

//mostrar la tabla<br />

for ($i=1;$i<br />

Solución del ejercicio 3<br />

<br />

http://www.eni-training.com/client_net/mediabook.aspx?idR=87314 3/5<br />

www.FreeLibros.me

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!