哪里错了,请指教
#include <stdio.h>
int main()
{
int i,j,sum = 0;
int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
for(i=0,i<3,i++)
{
for(j=o,j<3,j++)
{
if(i!=1 && j!=1)
sum = sum + arr[i][j];
}
}
sum=sum+arr[1][1];
printf("对角线元素之和是:%d\n",sum);
return 0;
}
#include <stdio.h>
int main()
{
int i,j,sum = 0;
int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
for(i=0,i<3,i++)
{
for(j=o,j<3,j++)
{
if(i!=1 && j!=1)
sum = sum + arr[i][j];
}
}
sum=sum+arr[1][1];
printf("对角线元素之和是:%d\n",sum);
return 0;
}
2017-02-23
举报