第1个回答 2018-06-24
#include <iostream>
const int N = 4;
int sumOfDiagonal(int num[][N])
{
int res = 0;
for(int i = 0; i < N; ++i)
res += num[i][i];
return res;
}
int main()
{
int a[N][N] = {11, 22 ,33 ,44,
25, 35 ,45 ,55,
18, 28, 38, 48,
55, 66, 77, 88};
int res = sumOfDiagonal(a);
std::cout << res << std::endl;
return 0;
}