code4sk/c/sourcecode/朱森森带领的奇妙冒险/2022-2023第二学期单开班第3次月考/7-4 矩阵运算.cpp
2023-10-18 16:17:32 +08:00

49 lines
676 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
7-4 ????
?? 10
?? C???
?? ????
????n×n???,??????????????????????????????????????????????????????
????:
??????????n(1<n=10);??n?,????n???,????????
????:
??????????????????????????????????
????:
4
2 3 4 1
5 6 1 1
7 1 8 1
1 1 1 1
????:
35
*/
#include<stdio.h>
int main()
{
int n,i,j,sum=0;
scanf("%d",&n);
int A[100][100];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&A[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(!((i==i&j==n-i-1)||i==n-1||j==n-1))
{
sum+=A[i][j];
}
}
}
printf("%d",sum);
return 0;
}