#include #include #include using namespace std; void splitArray(const vector& arr) { vector odd, even; // Separate even and odd numbers for (int num : arr) { if (num % 2 == 0) even.push_back(num); else odd.push_back(num); } // Sort both arrays sort(odd.begin(), odd.end()); sort(even.begin(), even.end()); // Print odd numbers in a single line for (size_t i = 0; i < odd.size(); i++) { cout << odd[i]; if (i != odd.size() - 1) cout << " "; } cout << endl; // Print even numbers in a single line for (size_t i = 0; i < even.size(); i++) { cout << even[i]; if (i != even.size() - 1) cout << " "; } cout << endl; } int main() { vector arr = {9, 8, 7, 6, 5, 4, 3, 2, 1}; splitArray(arr); return 0; }