# TOPIC

como posso diminuir o tempo de execução

#### Erick Santos asked 3 years ago

include

int main(){ int numero, i; scanf("%d", &numero); int vetor[numero]; for(i=0;i<numero;i++){ scanf("%d", &vetor[i]); } int npar = 0; int nimpar = 0; for(i=0;i<numero;i++){ if(vetor[i] % 2 == 0){ npar++; } else{ nimpar++; } } int vpar[npar], vimpar[nimpar]; int p = 0; int m = 0; for(i=0;i<numero;i++){ if(vetor[i] % 2 == 0){ vpar[p] = vetor[i]; p++; } else{ vimpar[m] = vetor[i]; m++; } } int aux; int k; for(i=0;i<npar;i++){ for(k=0;k<npar;k++){ if(vpar[i]<vpar[k]){ aux = vpar[i]; vpar[i] = vpar[k]; vpar[k] = aux; k = 0; } } } for(i=0;i<nimpar;i++){ for(k=0;k<nimpar;k++){ if(vimpar[i]>vimpar[k]){ aux = vimpar[i]; vimpar[i] = vimpar[k]; vimpar[k] = aux; k = 0; } } } for(i=0;i<npar;i++){ printf("%d\n", vpar[i]); } for(i=0;i<nimpar;i++){ printf("%d\n", vimpar[i]); } return 0; }

Remember not post solutions. Your post may be reviewed by our moderators.

• #### Roddas Cabral replied 2 years ago

Tente usar o qsort