Skip to content

Instantly share code, notes, and snippets.

@danilodorgam
Created April 6, 2015 21:40
Show Gist options
  • Save danilodorgam/70fcd61c80ec7b54695b to your computer and use it in GitHub Desktop.
Save danilodorgam/70fcd61c80ec7b54695b to your computer and use it in GitHub Desktop.
//Objetivo: Separar os números em par e impar //Parametros: Referencia ao vetor e tamanho do vetor //retono: Void
//Objetivo: Separar os números em par e impar
//Parametros: Referencia ao vetor e tamanho do vetor
//retono: Void
void trocaParImpar(int *num, int qtd){
int cont, cont2, par=0, impar=0;
for( cont=0; cont < qtd; cont++ ){
for( cont2 = qtd- 1; cont2 > cont; cont2-- ){
if( *(num+cont)%2==0 ){
par=*(num+cont);
}else{
impar= *(num+cont);
}
if(*(num+cont2)%2!=0){
impar= *(num+cont2);
}else{
par = *(num+cont2);
}
*(num+cont)= par;
*(num+cont+1)= impar;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment