1
Good afternoon, I’m having a problem with a vector ordering exercise, I’ve reviewed the code, it compiles, but I’m not finding the error so the order does not get crescent, varying in certain parts. Follow the code below:
#include <stdio.h> //Declaracao de bibliteca para entradas e saidas de valores
int main (void) //Declaracao do programa principal
{
int i, j, troca, vetorA[10];
for (i = 0; i < 10 ; i++)
{
printf("Digite o valor do elemento:");
scanf("%d", &vetorA[i]);
}
for(i=0; j<10; i++)
{
for (j=i+1; j<10; j++)
{
if(vetorA[i]>vetorA[j])
{
troca=vetorA[i];
vetorA[i] = vetorA[j];
vetorA[j] = troca;
}
}
}
printf("\nvetor ordenado \n");
for(i=0; i<10; i++)
{
printf("%d - ", vetorA[i]);
}
system("pause");
return 0;
}