Skip to content

Instantly share code, notes, and snippets.

@lucascaires
Created December 16, 2016 19:21
Show Gist options
  • Save lucascaires/9b6af81850e28aa3a90c4dddeb70af60 to your computer and use it in GitHub Desktop.
Save lucascaires/9b6af81850e28aa3a90c4dddeb70af60 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define count 5 //Define a constante com o tamanho do vetor
void main(void) {
//Define as variaveis
int valores[count], i, aux, prox;
//Loop para alimentar o vetor
for (i=0;i<count;i++) {
printf("Digite um numero inteiro: ");
scanf("%d", &valores[i]);
}
//Loop para ordenar o vetor
do {
prox = 0;
for(i=0;i<count-1;i++) {
if(valores[i] > valores[i + 1]) {
aux = valores[i];
valores[i] = valores[i + 1];
valores[i + 1] = aux;
prox = 1;
}
}
} while(prox);
//Loop para exibir os valores ordenados
for(i=0;i < count; i++) {
printf("%d ", valores[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment