Advertisement
Guest User

sort

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