int n = nums.size(),j=0; for(int i =n-1; i> 0;i--){ cout<<nums[n-1]<<endl; if(nums[i]%2==0){ swap(nums[i],nums[j]); j++; } }