Last active
July 6, 2016 20:49
-
-
Save RamonLopezEscudero/456e122660e4ddf213ec764c645639a5 to your computer and use it in GitHub Desktop.
Ordenamiento de datos por el algoritmo "Bubblesort"
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
#include <stdio.h> | |
int main() | |
{ | |
int i, j, temp, n; | |
int list[10] = {23, 17, 5, 90, 12, 44, 38, 84, 77, 1}; | |
n = sizeof(list)/sizeof(int); | |
for (i = 0; i < n - 1; i++) | |
{ | |
for (j = 0; j < n - 1; j++) | |
{ | |
if (list[j] < list[j+1]) | |
{ | |
/* Do nothing */ | |
; | |
} | |
else | |
{ | |
temp = list[j+1]; | |
list[j+1] = list[j]; | |
list[j] = temp; | |
} | |
} | |
} | |
printf("La lista ordenada queda:\n"); | |
for (i = 0; i < n; i++) | |
{ | |
printf("%i ", list[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment