Created
December 16, 2016 19:21
-
-
Save lucascaires/9b6af81850e28aa3a90c4dddeb70af60 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
#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