矩阵求和的一条对角线结果为啥不对?
#include<stdio.h>int main()
{
int i,j,sum1=0,sum2=0;
int a={{1,2,3},{4,5,6},{7,8,9}};
for(i=0;i<3;i++)
sum1+=a;
sum2+=a;
printf("%d %d",sum1,sum2);
}
结果sum2=9。。。?咋回事呀 #include<stdio.h>
int main()
{
int i,j,sum1=0,sum2=0;
int a={{1,2,3},{4,5,6},{7,8,9}};
//循环要把sum2包含进去
for(i=0;i<3;i++)
{
sum1+=a;
sum2+=a;
}
printf("%d %d",sum1,sum2);
return 0;
}
页:
[1]