Advertisement
Sanabio

Par/Impar

Dec 18th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<locale.h>
  4.  
  5. int main( ){
  6.    
  7.     setlocale(LC_ALL, "Portuguese");
  8.  
  9.     int vet[10], vetp[10], veti[10], i, j = 0;
  10.    
  11.     printf("\t\tPreenchendo o vetor\n\n");
  12.    
  13.     for(i = 0; i <= 10; i++){
  14.         printf("\nDigite um número: ");
  15.         scanf("%d", &vet[i]);
  16.     }
  17.  
  18.     system("cls");
  19.  
  20.     for(j = 0; j <= 10; j++){
  21.         if(vet[j] % 2 == 0)  //pega o resto da divisão inteira e compara com 0
  22.             vetp[j] = vet[j];
  23.         }
  24.         else{
  25.             veti[j] = vet[j];
  26.         }
  27.     }
  28.    
  29.     printf("\n\n\t\tVetor inicial\t\tVetor par\t\tVetor impar\n\n");
  30.  
  31.     for(j = 0; j <= 10; j++){
  32.         printf("\t\t%d\t\t%d\t\t%d\n", vet[j], vetp[j], veti[j]);
  33.     }
  34.    
  35.     puts("\n\n");
  36.     system("pause");
  37.     return(0);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement