Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Find the sum of the positive diagonal, the sum of the negative diagonal and the sum of each row and column of a 3*3 shaping matrix. C language programming.
Find the sum of the positive diagonal, the sum of the negative diagonal and the sum of each row and column of a 3*3 shaping matrix. C language programming.
# include & ltstdio.h & gt

# include & ltconio.h & gt

int main()

{

int a[3][3] = {{ 1,2,3},{4,5,6},{7,8,9 } };

int col[3]= { 0 }; //hang

int row[3]= { 0 }; //lie

int Zhu = 0;

int fu = 0;

int I;

int j;

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

{

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

{

If (j == i)

{

Zhu+= a[I][j];

}

If (i+j == 2)

{

fu+= a[I][j];

}

col[I]+= a[I][j];

row[I]+= a[j][I];

}

}

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

{

printf(" %d ",col[I]);

}

printf(" \ n ");

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

{

Printf(" %d ",line [i]);

}

printf("\nzhu = %d\n ",Zhu);

printf("fu = %d ",fu);

System ("suspended");

Returns 0;

}