Created
April 6, 2015 21:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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