Last active
May 23, 2018 19:20
-
-
Save OldLipe/6073a8da2f10abee7e1f3c87c6f2b073 to your computer and use it in GitHub Desktop.
Basic example of bubble sort
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 *ordenador(int lista[],int tamanho){ | |
int i,j,aux; | |
for (i = 0;i<tamanho;i++){ | |
for (j = 1 + i;j<tamanho;j++){ | |
if (lista[i] > lista[j]){ | |
aux = lista[i]; | |
lista[i] = lista[j]; | |
lista[j] = aux; | |
} | |
} | |
} | |
return(lista); | |
} | |
void mostrar(int *lista){ | |
int tamanho,i; | |
for (i =0,tamanho = (sizeof(lista)/sizeof(*lista));i<=tamanho;i++){ | |
printf("%d\n",lista[i]); | |
} | |
} | |
int main(void){ | |
int i,number[3],tamanhoLista; | |
for(i =0;i<3;i++){ | |
scanf("%d",&number[i]); | |
} | |
int *lista = ordenador(number,tamanhoLista); | |
mostrar(lista); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment