Hi, I wanted help solving a problem with c++
:
I am making a code and I used the selection sort but it has a bug in the results output
void select_sort (int vetor [TAM])
{
int menor,aux;
cout << "Digite as 5 posicoes, de maneira que preencha as posicoes do nosso vetor " << endl;
cout << " "<< endl;
for(int i = 0; i < TAM; i++)
{
menor = i;
for(int j = i + 1; j < TAM; j++)
{
if(vetor[menor] > vetor[j])
menor = j;
if(i != menor)
aux=vetor[i];
vetor[i] = vetor[menor];
vetor [menor] = aux;
}
}
cout << " o vetor fica assim:" << endl;
cout << " " << endl;
for(int i = 0; i < TAM; i++)
{
cout << vetor[i] << " | ";
}
cout << " " << endl;
}
In case it is a function Can someone help me?
problem: I enter 1,2,3,2,1
it exits: 1,2,2,3,30
What I do