Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. int main(int argc, char *argv[]) {
  2. int *poljeA;
  3. int *poljeB;
  4. int *poljeC;
  5. int i,k,brojac1=0,brojac2=0,N,c;
  6. scanf("%d",&N);
  7. poljeA = (int *) malloc (N * sizeof(int));
  8.  
  9. for(i=0;i<N;i++){
  10. scanf("%d",&*(poljeA+i));
  11. if(*(poljeA+i)%2==0){
  12. brojac1++;
  13. }
  14. else if(*(poljeA+i)%2==1){
  15. brojac2++;
  16.  
  17. }
  18. }
  19. poljeB = (int *) malloc (brojac1 * sizeof(int));
  20. poljeC = (int *) malloc (brojac2 * sizeof(int));
  21. k = 0;
  22. c = 0;
  23. for(i=0;i<N;i++){
  24. if(*(poljeA+i)%2==0){
  25. *(poljeB+k)=*(poljeA+i) ;
  26. k++;
  27. }
  28. else if(*(poljeA+i)%2==1){
  29. *(poljeC+c)=*(poljeA+i) ;
  30. c++;
  31.  
  32. }
  33. }
  34.  
  35. for(i=0;i<brojac1;i++){
  36.  
  37. printf("%d",*(poljeB+i));
  38. }
  39. printf("\n");
  40. for(i=0;i<brojac2;i++){
  41.  
  42. printf("%d",*(poljeC+i));
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement