Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Find the sum of diagonal elements of a 3*3 plastic matrix, and the C language program helps debugging.
Find the sum of diagonal elements of a 3*3 plastic matrix, and the C language program helps debugging.
# Including

Internationalorganizations (same as international organizations)

Master ()

{

Internationalorganizations (same as international organizations)

I,j,a[3][3],sum = 0;

Printf ("Please enter data: \ n");

for(I = 0; I<3; i++)

for(j = 0; j & lt3; j++)

scanf("%d ",& ampa[I][j]);

printf(" array is:\ n ");

for(I = 0; I<3; i++)

{

for(j = 0; j & lt3; j++)

printf("%d\t ",a[I][j]);

printf(" \ n ");

}

Printf ("\ nSum of diagonal lines: \ n");

for(I = 0; I<3; i++)

{

for(j = 0; j & lt3; j++)

if(I = = j | | 2-I = = j){ sum = sum+a[I][j]; }

}

printf("%d\n ",sum);

return

0;

}

The first level is correct, because the tables under the array are counted from 0, that is, a[3][3] actually stores A [0] [0], A [0] [1], A [0] [2], A [1] [0], A.