#include #include #include using namespace std; void findMinimumMatrix(vector>& matrix, vector& extraNumbers) { vector allNumbers; // Flatten the 3x3 matrix into a 1D array for (const auto& row : matrix) { for (int num : row) { allNumbers.push_back(num); } } // Add the extra numbers for (int num : extraNumbers) { allNumbers.push_back(num); } // Sort all numbers sort(allNumbers.begin(), allNumbers.end()); // Output the smallest 9 numbers in a 3x3 format for (int i = 0; i < 9; i++) { cout << allNumbers[i] << " "; if ((i + 1) % 3 == 0) cout << endl; // New line after every 3 numbers } } int main() { vector> matrix = { {2, 4, 6}, {8, 10, 12}, {14, 16, 18} }; vector extraNumbers = {1, 3, 5, 7, 9}; findMinimumMatrix(matrix, extraNumbers); return 0; }