The even numbers I was able to sort, only odd numbers I can not sort. The number memory address is displayed.
Link to the question: Couple and Odd ones
Here's my code:
#include <stdio.h>
int main(int argc, char** argv)
{
int teste, i, j, aux, aux1, c1 = 0, c2 = 0;
scanf("%d", &teste);
int vetor[teste], par[teste], impar[teste];
for(i = 0; i < teste; i++)
{
scanf("%d", &vetor[i]);
}
for(i = 0; i < teste; i++)
{
if(vetor[i] % 2 == 0)
{
par[i] = vetor[i];
c1++;
}
else
{
impar[i] = vetor[i];
c2++;
}
}
for(i = 0; i < teste - 1; i++)
{
for(j = i + 1; j < teste; j++)
{
if(par[i] > par[j])
{
aux = par[i];
par[i] = par[j];
par[j] = aux;
}
}
}
for(i=0;i<teste-1;i++)
{
for(j=i+1;j<teste;j++)
{
if(impar[i]<impar[j])
{
aux1=impar[i];
impar[i]=impar[j];
impar[j]=aux1;
}
}
}
for(i=0;i<c1;i++)
{
printf("%d\n",par[i]);
}
for(i=0;i<c2;i++)
{
printf("%d\n",impar[i]);
}
return 0;
}