0
Well, I was trying to sort a vector in even and odd, that is, half the vector is even and the other odd. It worked "almost" perfectly.
The problem is that the last position always ended up being par. And I could not find the mistake.
From now on, gratitude.
#include <stdio.h>
int main()
{
int vector[10];
int aux = 0;
printf("Digite 10 numeros a serem ordenados em par e impar:\n");
for (int x = 0; x < 10; x++) {
scanf("%d", &vector[x]);
}
for (int i = 0; i < 10; i++) {
for (int j = 10; j > 0; j--) {
if (vector[i] % 2 == 1) {
aux = vector[i];
vector[i] = vector[j];
vector[j] = aux;
}
}
}
for (int t = 0; t < 10; t++) {
printf("%d", vector[t]);
}
return 0;
}
Excuse me, but what was the mistake in the loop? I have not yet identified kk
– Jackson Burnley
It was their range, it didn’t cover the whole vector, the last position was out of comparison.
– FourZeroFive