Advertisement
Sanlover

Untitled

Oct 25th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. //g++ 7.4.0
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int array[10] = {1,5,6,8,7,4,9,10,22,13};
  9. for(int i = 5; i < 10; i++) {
  10. if(array[i] %2 == 0) {
  11. for( int j = 0; j < 5 ; j++ ) {
  12. if( array[j] % 2 != 0) {
  13. int temp = array[i];
  14. array[i] = array[j];
  15. array[j] = temp;
  16. }
  17. }
  18. }
  19. }
  20. for(int i = 0; i<10; i++){
  21. cout << array[i] << ' ';
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement