#include
int main()
{
int a[3][3] = {{9,8,7},{1,2,3},{4,5,6}};
int i, j , s1 = 0, min = 10000000, m, n; //s1为对角线元素和,min为最小值,a,b为下标标记
printf("二维数组如下:\n");
for(i = 0; i < 3; i++) //要求1
{
for(j = 0; j < 3; j++)
printf("%2d",a[i][j]);
printf("\n");
}
for(i = 0; i < 3; i++) //要求2
{
s1+=a[i][i];
}
printf("对角线元素之和为: %d\n",s1);
for(i = 0; i < 3; i++) //要求3
{
for(j = 0; j < 3; j++)
{
if(min > a[i][j])
{
min = a[i][j];
m = i;
n = j;
}
}
}
printf("最小的元素为:a[%d][%d] = %d\n",m,n,min);
return 0;
}