3
My problem is that I can’t eliminate repeat numbers. First thing my algorithm does is organize the elements, then in the eleminar_numeros_repeated copy method to second vector which is vec1.Only after I start to delete.
Arquivo função1.c:
void organizar_vetor(int *vec, int n){
int i,j;
for(i=0 ; i <n-1; i=i+1)
{
for(j=i+1 ; j<n ; j=j+1)
{
if (*(vec +i) >*(vec+j))
{
int aux =*(vec+i);
*(vec+i)=*(vec+j);
*(vec+j)=aux;
}
}
}
}
int eleminar_numeros_repetidos(int *vec, int n, int *vec1){
organizar_vetor(vec,n);
int i,j;
for(i=0 ; i <n-1; i++)
{
for(j=i+1 ; j<n ; j++)
{
vec1[i]=vec[i];
if (vec1[i] == vec1[j])
{
int k;
for (k = j; k <n-1 ; k++)
{
vec1[k]=vec1[k+1];
j--;n--;
}
}
}
}
return n;
}