1. This is an English-language forum. I have translated the Spanish parts for you, but we would appreciate it if you could provide them in English in the future.
It would also help if the function names were more readable for us:
void fill_matrix_with_number(int num, char c, vector<vector<char>> &matrix)
void print_matrix(int num, char c, int ROWS, int COLUMNS, vector<vector<char>> &matrix)
2. Please use appropriate code tags to make your source code easier to read. I have used C++ code tags here.
3. The code appears incomplete or disorganized. It’s possible that something got mixed up when copying.
The function fill_matrix_with_number() is expected to initialize matrices of arbitrary size, but due to the current switch-case implementation, it only initializes a limited number of elements. You should consider using for loops, similar to how they are used for output.
4. There might also be issues in the function print_matrix. The provided code snippet does not contain all the necessary information.
Note: The initialization of the matrix is not provided here. It would be important to know the actual size. If the matrix is supposed to have the dimensions ROWS * COLUMNS, this needs to be ensured before writing values into it. Accessing non-existent elements would cause errors.
If the matrix is expected to have the size ROWS * COLUMNS, the index boundaries in the loops must be respected. The existing code appears to exceed the valid range when accessing elements.
// edit: The parameters ROWS and COLUMNS are not needed in the print_matrix() function if you always intend to print the entire matrix. Vector objects already contain the size.
You can get the size of the matrix like this:
size_t rows = matrix.size();
size_t columns = matrix[0].size();
This way, you don't need to pass ROWS and COLUMNS as parameters, and the function can dynamically adapt to the matrix size.