#include <stdio.h>
int main(int argc, int *argv[])
{
int a[3][3] = {{4,8,34},{35,86,32},{100,39,73}};
int line1 = 0, line2 = 0;
int i,j;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
if (i == j)
{
line1 += a[i][j];
}
if (2 == i + j)
{
line2 +=a[i][j];
}
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\n");
printf("the line1 sum is : %d\n",line1);
printf("the line2 sum is : %d\n",line2);
system("pause");
return 0;
}
|