#include #include #include using namespace std; int main() { const int ROWS = 4, COLS = 4; int arr[ROWS][COLS]; for (int i = 0; i < ROWS; ++i) { for (int j = 0; j < COLS; ++j) { cin >> arr[i][j]; } } int n; cin >> n; vector inputNumbers(n); for (int i = 0; i < n; ++i) { cin >> inputNumbers[i]; } vector allNumbers; for (int i = 0; i < ROWS; ++i) { for (int j = 0; j < COLS; ++j) { allNumbers.push_back(arr[i][j]); } } for (int num : inputNumbers) { allNumbers.push_back(num); } sort(allNumbers.rbegin(), allNumbers.rend()); vector largestNumbers(allNumbers.begin(), allNumbers.begin() + 16); for (int i = 0; i < ROWS; ++i) { for (int j = 0; j < COLS; ++j) { cout << largestNumbers[i * COLS + j] << " "; } cout << endl; } return 0; }