Here's an example Python code snippet that formats a matrix and a list of column names into a table in console output:

```
def print_table(matrix, column_names):
    # Determine the maximum width of each column based on the length of the column names
    column_widths = [max(len(str(name)), max(len(str(row[i])) for row in matrix)) for i, name in enumerate(column_names)]
    
    # Print the column headers
    header = "| " + " | ".join(name.center(width) for name, width in zip(column_names, column_widths)) + " |"
    separator = "+-" + "-+-".join("-" * width for width in column_widths) + "-+"
    print(separator)
    print(header)
    print(separator)
    
    # Print each row of the matrix
    for row in matrix:
        row_str = "| " + " | ".join(str(val).ljust(width) for val, width in zip(row, column_widths)) + " |"
        print(row_str)
    
    # Print the footer separator
    print(separator)
```

To use this function, you can pass in your matrix (a list of lists) and a list of column names:

```python
matrix = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
]
column_names = ["A", "B", "C"]

print_table(matrix, column_names)
```

This would print the following table:

```
+---+---+---+
| A | B | C |
+---+---+---+
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
+---+---+---+
```
Scrivere un programma per formattare una data matrice e un elenco di nomi di colonna in una tabella nell'output della console.