#include
int main()
{
int a[5][5] =
{
{1,2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15},
{16,17,18,19,20},
{21,22,23,24,25}
};
int i,j,s=0;
for(i=0;i<5;i++)
{
s+=a[i][i];
if(i!=4-i) /*对角线上有一个[2][2]重复计算的要去掉*/
s+=a[i][4-i];
}
printf("%d", s);
return 0;
}
sum = a[0][0] + a[1][1]+ a[2][2]+ a[3][3]+ a[4][4];
sum += a[4][0] + a[3][1]+ a[2][2]+ a[1][3]+ a[0][4];
#include
int main()
{
int i, j, a[5][5], sum1=0/*, sum2=0*/;
for (i = 0; i < 5; ++i){
for (j = 0; j < 5; ++j){
scanf ("%d", &a[i][j]);
}
}
for (i = 0; i < 5; ++i){
sum1 += a[i][i];
//sum2 += a[i][4-i];
}
printf ("%d\n", sum1);
return 0;
}