import java.util.Scanner;
public class Fang{
public static void main(String args[]){
System.out.println("请输入一个方阵");
int n=5;
int a[][]=new int[n][n];
Scanner input=new Scanner(System.in);
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=input.nextInt();
}
}
int sum1=0;
int sum2=0;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(i==j)
sum1+=a[i][j];
if(i+j==n)
sum2+=a[i][j];
}
}
System.out.println("主对角线的和="+sum1);
System.out.println("副对角线的和="+sum2);
}
}
public class Fang{
public static void main(String args[]){
System.out.println("请输入一个方阵");
int n=5;
int a[][]=new int[n][n];
Scanner input=new Scanner(System.in);
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=input.nextInt();
}
}
int sum1=0;
int sum2=0;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(i==j)
sum1+=a[i][j];
if(i+j==n)
sum2+=a[i][j];
}
}
System.out.println("主对角线的和="+sum1);
System.out.println("副对角线的和="+sum2);
}
}