Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
122350 李昊宇 对角线之和 C++ Accepted 1 MS 284 KB 421 2025-06-15 15:08:55

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; int a[101][101],b[101][101]; int main(){ int n,m; double sum=0; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cin>>a[i][j]; b[i][n+1-j] = a[i][j]; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==j){ sum+=a[i][j]; } else if(n+1==i+j){ sum+=a[i][j]; } } } cout<<sum<<endl; return 0; }