I'm trying to do a program to sort vector and I'm using an auxiliary function to do this, but I'm getting this error message.
/media/isaque/dados/exercicios/c/scripts/estrutura de dados com c++/busca_binaria.cpp: In function ‘void ordenar_vetor(int*)’:
/media/isaque/dados/exercicios/c/scripts/estrutura de dados com c++/busca_binaria.cpp:38:7: warning: variable ‘aux’ set but not used [-Wunused-but-set-variable]
int aux;
This is my script
#include <iostream>
#include <random>
#define TAM 15
int main()
{
void ordenar_vetor(int *vetor);
int gerar_aleatorio();
int valores[TAM];
for(int c = 0; c < TAM; c++ )
{
valores[c] = gerar_aleatorio();
}
ordenar_vetor(valores);
for(int c = 0; c < TAM; c++ )
{
std::cout << valores[c] << std::endl;
}
return 0;
}
int gerar_aleatorio()
{
std::random_device m;
std::uniform_int_distribution<int> gerar(1,100);
return gerar(m);
}
void ordenar_vetor(int *vetor)
{
int aux;
for(int c = 0; c < TAM; c++)
{
for(int i = 0; i < TAM; c++)
{
if(vetor[c] < vetor[i])
{
aux = vetor[i];
vetor[i] = vetor[c];
vetor[c] = vetor[i];
}
}
}
}
I can not identify where I'm going wrong