5*5数组
1 3 5 7 9
2 4 6 8 10
2 3 4 5 6
4 5 6 7 8
1 3 4 5 6
计算交叉线上数之和
代码实现:
#include <stdio.h>
int fun(int a[5][5])
{
return a[0][0] + a[1][1] + a[2][2] + a[3][3] + a[4][4] + a[0][4] + a[1][3] + a[3][1] + a[4][0];
}
int main()
{
int a[5][5] = { {1,3,5,7,9} ,{2,4,6,8,10}, {2,3,4,5,6}, {4,5,6,7,8}, {1,3,4,5,6} };
int y = 0;
y = fun(a);
printf("s=%d\n",y);
return 0;
}