Advertisement
Guest User

sort

a guest
Oct 15th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using std::cout;
  4.  
  5. void sort(int a[], int nArray)
  6. {
  7. int *nechet = new int[nArray];
  8. int *chet = new int[nArray];
  9. int i;
  10. int countChet = 0;
  11. int countNechet = 0;
  12.  
  13. for (i = 0; i < nArray; ++i)
  14. {
  15. if (a[i] % 2 > 0)
  16. {
  17. nechet[countNechet] = a[i];
  18. ++countNechet;
  19. }
  20. else
  21. {
  22. chet[countChet] = a[i];
  23. ++countChet;
  24. }
  25. }
  26.  
  27. cout << "Your new array: ";
  28. for (i = 0; i < countChet; ++i)
  29. {
  30. cout << chet[i] << " ";
  31. }
  32.  
  33. for (i = 0; i < countNechet; ++i)
  34. {
  35. cout << nechet[i] << " ";
  36. }
  37.  
  38. delete[] chet;
  39. delete[] nechet;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement