#include #include #include using namespace std; int main() { // Get input array size int n; cout << "Enter the size of the array: "; cin >> n; // Input the array elements vector arr(n); cout << "Enter the array elements: "; for (int i = 0; i < n; ++i) { cin >> arr[i]; } // Vectors to store even and odd numbers vector evenArr; vector oddArr; // Iterate through the array and split even and odd numbers for (int i = 0; i < n; ++i) { if (arr[i] % 2 == 0) { evenArr.push_back(arr[i]); } else { oddArr.push_back(arr[i]); } } // Sort the even and odd arrays sort(evenArr.begin(), evenArr.end()); sort(oddArr.begin(), oddArr.end()); // Output the sorted even array cout << "Sorted even array: "; for (int i = 0; i < evenArr.size(); ++i) { cout << evenArr[i] << " "; } cout << endl; // Output the sorted odd array cout << "Sorted odd array: "; for (int i = 0; i < oddArr.size(); ++i) { cout << oddArr[i] << " "; } cout << endl; return 0; }