1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】8.数组2/7-4 矩阵运算.c

26 lines
459 B
C
Raw Normal View History

2024-11-13 03:09:36 +00:00
#include <stdio.h>
int n, mat[15][15], sum = 0;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
scanf("%d", &mat[i][j]);
}
}
for (int i = 1; i <= n - 1; i++) {
for (int j = 1; j <= n - 1; j++) {
if (i + j != n + 1) { // 剔除副对角线
sum += mat[i][j];
}
}
}
printf("%d\n", sum);
return 0;
}