求一个3*3的整形矩阵对角线元素之和
时间: 2023-06-04 12:04:02 浏览: 191
C++求一个3×3矩阵对角线元素之和
Sure, the sum of the diagonal elements of a 3x3 matrix can be calculated as follows:
```
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
sum = matrix[0][0] + matrix[1][1] + matrix[2][2]
```
The result should be 15.
阅读全文