Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
156763 邓弘锐 对角线之和 C++ Accepted 9 MS 300 KB 383 2026-07-10 14:01:10

Tests(10/10):


Code:

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