#include #include #include using namespace std; int main() { // Input the numbers vector numbers; int num; while (cin >> num) { numbers.push_back(num); if (cin.get() == '\n') break; // To handle single line input } vector odd, even; // Split into odd and even numbers for (int n : numbers) { if (n % 2 == 0) even.push_back(n); else odd.push_back(n); } // Sort both arrays sort(odd.begin(), odd.end()); sort(even.begin(), even.end()); // Output odd numbers for (int i = 0; i < odd.size(); i++) { cout << odd[i] << (i == odd.size() - 1 ? "\n" : " "); } // Output even numbers for (int i = 0; i < even.size(); i++) { cout << even[i] << (i == even.size() - 1 ? "\n" : " "); } return 0; }