0
hi wanted a help to solve a problem of c++
:
I am making a code and used Selection Sort but it is with a bug in the output results
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 someone could help me out
problem : insert 1,2,3,2,1
he comes out : 1,2,2,3,30
What do I do