CONTENIDO DE LA LECCIÓN 18
CONTENIDO DE LA LECCIÓN 18 CONTENIDO DE LA LECCIÓN 18
MIGUEL Á. TOLEDO MARTÍNEZ Ejemplo 18.26 El siguiente programa, BURBUJA1.CPP, ordena los valores del arreglo de diez elementos arreglo en orden ascendente. La técnica de la que nos valemos se llama ordenamiento de burbuja u ordenamiento por hundimiento(dependiendo si se ordena en orden descendente o ascendente), pues los valores más pequeños gradualmente burbujean hacia la parte alta del arreglo como las burbujas de aire que ascienden en el agua, mientras que los valores más grandes se hunden al fondo del arreglo. La técnica es pasar varias veces por el arreglo. En cada pasada, se comparan pares sucesivos de elementos. Si uno de los pares está en orden ascendente (o son idénticos los valores), se queda tal cual. Si está en orden descendente, se intercambian sus valores en el arreglo. /* El siguiente programa: BURBUJA1.CPP, ordena los valores de un arreglo en orden ascendente utilizando el método de la burbuja. */ #include //Para cout y cin #include //Para setw() void main(void) { const int TAMANO_ARREGLO = 10; int arreglo[TAMANO_ARREGLO] = {2, 6, 4, 8, 10, 12, 89, 68, 45, 37}; int i, temporal; cout
MIGUEL Á. TOLEDO MARTÍNEZ Ejemplo 18.27 El problema anterior puede mejorarse solicitando el número de datos a ordenar, llamaremos a este programa, BURBUJA2.CPP. Es importante que observe algunos cambios que hicimos en la función clasifBurbuja() /* El siguiente programa: BURBUJA2.CPP, ordena arreglos usando el método de ordenamiento de la burbuja. */ #include //Para cout y cin const int MIN = 2; const int MAX = 10; int obtenNumPuntos(int minimo, int maximo) { int numPuntos; do return numPuntos; }//Fin de obtenNumPuntos() { cout
- Page 1 and 2: MIGUEL Á. TOLEDO MARTÍNEZ CONTENI
- Page 3 and 4: MIGUEL Á. TOLEDO MARTÍNEZ LECCIÓ
- Page 5 and 6: MIGUEL Á. TOLEDO MARTÍNEZ ELEMENT
- Page 7 and 8: MIGUEL Á. TOLEDO MARTÍNEZ Con las
- Page 9 and 10: MIGUEL Á. TOLEDO MARTÍNEZ del arr
- Page 11 and 12: MIGUEL Á. TOLEDO MARTÍNEZ // MUES
- Page 13 and 14: MIGUEL Á. TOLEDO MARTÍNEZ que exp
- Page 15 and 16: MIGUEL Á. TOLEDO MARTÍNEZ Ejemplo
- Page 17 and 18: MIGUEL Á. TOLEDO MARTÍNEZ Ejemplo
- Page 19 and 20: MIGUEL Á. TOLEDO MARTÍNEZ void ma
- Page 21 and 22: MIGUEL Á. TOLEDO MARTÍNEZ PASO DE
- Page 23 and 24: MIGUEL Á. TOLEDO MARTÍNEZ void pa
- Page 25 and 26: MIGUEL Á. TOLEDO MARTÍNEZ Ejemplo
- Page 27 and 28: MIGUEL Á. TOLEDO MARTÍNEZ int bus
- Page 29 and 30: MIGUEL Á. TOLEDO MARTÍNEZ El cuer
- Page 31: MIGUEL Á. TOLEDO MARTÍNEZ /******
- Page 35 and 36: MIGUEL Á. TOLEDO MARTÍNEZ Ejemplo
- Page 37 and 38: MIGUEL Á. TOLEDO MARTÍNEZ /* El s
- Page 39 and 40: MIGUEL Á. TOLEDO MARTÍNEZ escribi
- Page 41 and 42: MIGUEL Á. TOLEDO MARTÍNEZ /* El s
- Page 43 and 44: MIGUEL Á. TOLEDO MARTÍNEZ Ejemplo
- Page 45 and 46: MIGUEL Á. TOLEDO MARTÍNEZ SOLUCI
- Page 47 and 48: MIGUEL Á. TOLEDO MARTÍNEZ // Busc
- Page 49 and 50: MIGUEL Á. TOLEDO MARTÍNEZ Paso 1
- Page 51 and 52: MIGUEL Á. TOLEDO MARTÍNEZ { j = i
- Page 53 and 54: MIGUEL Á. TOLEDO MARTÍNEZ un tama
- Page 55 and 56: MIGUEL Á. TOLEDO MARTÍNEZ necesit
- Page 57 and 58: MIGUEL Á. TOLEDO MARTÍNEZ { for (
- Page 59 and 60: MIGUEL Á. TOLEDO MARTÍNEZ // Comp
- Page 61 and 62: MIGUEL Á. TOLEDO MARTÍNEZ INICIAC
- Page 63 and 64: MIGUEL Á. TOLEDO MARTÍNEZ Esta ve
- Page 65 and 66: MIGUEL Á. TOLEDO MARTÍNEZ • Los
- Page 67 and 68: MIGUEL Á. TOLEDO MARTÍNEZ Es posi
- Page 69 and 70: MIGUEL Á. TOLEDO MARTÍNEZ p[100];
- Page 71 and 72: MIGUEL Á. TOLEDO MARTÍNEZ a) Cree
- Page 73 and 74: MIGUEL Á. TOLEDO MARTÍNEZ d) ¿cu
- Page 75 and 76: MIGUEL Á. TOLEDO MARTÍNEZ medio d
- Page 77 and 78: MIGUEL Á. TOLEDO MARTÍNEZ EXAMEN
MIGUEL Á. TOLEDO MARTÍNEZ<br />
Ejemplo <strong>18</strong>.27<br />
El problema anterior puede mejorarse solicitando el número de datos a ordenar, llamaremos a este programa,<br />
BURBUJA2.CPP. Es importante que observe algunos cambios que hicimos en la función clasifBurbuja()<br />
/* El siguiente programa: BURBUJA2.CPP, ordena arreglos usando el método de ordenamiento<br />
de la burbuja.<br />
*/<br />
#include //Para cout y cin<br />
const int MIN = 2;<br />
const int MAX = 10;<br />
int obtenNumPuntos(int minimo, int maximo)<br />
{<br />
int numPuntos;<br />
do<br />
return numPuntos;<br />
}//Fin de obtenNumPuntos()<br />
{<br />
cout