Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Write a C language program to define an array with three rows and three columns as shown in the figure, the type is integer, and complete the following questions:
Write a C language program to define an array with three rows and three columns as shown in the figure, the type is integer, and complete the following questions:

#include

int main()

{ int i,j,s1=0,s2=0,a[3] [3]= {9,8,7,1,2,3,4,5,6},i1=0,j1=0; printf("two-dimensional array:\n"); for(i=0; i<3; i++) { s1+=a[i][i];

s2+=a[i][2-i];

for(j=0; j <3; j++)

{ printf("%2d",a[i][j]);

? if(a[i][j]

? { i1=i;

j1=j;

? }

}

printf("\n"); } printf("Sum of main diagonals=%d\n",s1); printf("Sum of secondary diagonals=%d\n",s2); printf("The element with the smallest value in the array is: a[%d][%d]=%d\n",i1,j1,a[i1][j1]); return 0;

}