-
-
Save parzibyte/f21ddd1c7b5f8bb95a1845af559377da to your computer and use it in GitHub Desktop.
This file contains 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
void ordenarArreglo() | |
{ | |
int x; | |
for (x = 0; x < CANTIDAD_PERSONAS; x++) | |
{ | |
int indiceActual; | |
for (indiceActual = 0; indiceActual < CANTIDAD_PERSONAS - 1; | |
indiceActual++) | |
{ | |
int indiceSiguienteElemento = indiceActual + 1; | |
// Ordenar por altura, de manera descendente | |
if (personas[indiceActual].altura < personas[indiceSiguienteElemento].altura) | |
{ | |
// Intercambiar | |
memcpy(&temporal, &personas[indiceActual], sizeof(struct persona)); | |
memcpy(&personas[indiceActual], &personas[indiceSiguienteElemento], sizeof(struct persona)); | |
memcpy(&personas[indiceSiguienteElemento], &temporal, sizeof(struct persona)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment