fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main()
  5. {
  6. int ch[100], ch1[100], ch2[100], n, head=0, tile, head1=0, head2=0, tile1=0, tile2=0;
  7. printf("Input n: ");
  8. scanf("%d",&n);
  9. printf("\n");
  10. printf("Input elements: ");
  11. for(tile=0; tile<n; tile++)
  12. scanf("%d ",&ch[tile]);
  13. printf("\n");
  14. while(head<tile)
  15. {
  16. if(ch[head]%2==0)
  17. {
  18. ch1[tile1]=ch[head];
  19. tile1++;
  20. }
  21. else {
  22. ch2[tile2]=ch[head];
  23. tile2++;
  24. }
  25. head++;
  26. }
  27. head=0;
  28. tile=0;
  29. while(head1<tile1)
  30. {
  31. ch[tile]=ch1[head1];
  32. tile++;
  33. head1++;
  34. }
  35. while(head2<tile2)
  36. { ch[tile]=ch2[head2];
  37. tile++;
  38. head2++;
  39. }
  40. printf("Vidsortovana cherga: ");
  41. while(head<tile)
  42. {
  43. printf("%d ", ch[head]);
  44. head++;
  45. }
  46. return 0;
  47. }
  48.  
  49.  
  50.  
Success #stdin #stdout 0s 9432KB
stdin
3
1 2 3 
stdout
Input n: 
Input elements: 
Vidsortovana cherga: 2 1 3