提交时间:2019-12-20 19:49:12

运行 ID: 3589

#include<iostream> using namespace std; int main(){ int n,z=0,y=0,h,mid; cin>>n; int a[n][n]; for(int i=0;i<=n-1;i++){ for(int j=0;j<=n-1;j++){ cin>>a[i][j]; } } for(int i=0;i<=n-1;i++){ z+=a[i][i]; } for(int i=0;i<=n-1;i++){ y+=a[i][n-1-i]; } h=z+y; if(n%2!=0){ mid=a[n/2][n/2]; h-=mid; } cout<<h; return 0; }