第一次为45,第二次为25.
#include <stdio.h>
void main()
{
int i, j;
int sum1 = 0, sum2 = 0;
int a[3][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
for (i = 0; i<3; i++)
for (j = 0; j<3; j++)
sum1 += a[i][j];
printf("sum1 = %d\n", sum1);
for (i = 0; i<3; i++)
for (j = 0; j<3; j++)
if (i == j || i + j == 2)
sum2 += a[i][j];
printf("sum2 = %d\n", sum2);
while (1);
} 