public calss jiecheng{
public static void main(String args[]){
int n=0;
Scanner num=new Scanner(System.in);
System.out.printin("请输入阶数:");
n=num.nextint()
int[][] a=new int[n][n];
Scanner reader=new Scanner(System.in);
System.out.printin("请输入元素:");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
a[j][j]=reader.nextint();
}
}
int nm1,nm2,sum1=0;sum2=0,sum=0;
for(int i=0;i<n;i++){
nm1=a[i][i];
sum1=sum1+nm1;
}
for(int i=0,j=n-1;j<n;i++,j--){
nm2=a[i][j];
sum2=sum2+nm2;
}
sum=sum1+sum2;
System.out.printin(对角线上元素之和是"+sum");
}
public static void main(String args[]){
int n=0;
Scanner num=new Scanner(System.in);
System.out.printin("请输入阶数:");
n=num.nextint()
int[][] a=new int[n][n];
Scanner reader=new Scanner(System.in);
System.out.printin("请输入元素:");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
a[j][j]=reader.nextint();
}
}
int nm1,nm2,sum1=0;sum2=0,sum=0;
for(int i=0;i<n;i++){
nm1=a[i][i];
sum1=sum1+nm1;
}
for(int i=0,j=n-1;j<n;i++,j--){
nm2=a[i][j];
sum2=sum2+nm2;
}
sum=sum1+sum2;
System.out.printin(对角线上元素之和是"+sum");
}