1、c语言中求4行3列二维数组元素的和
#include
int main(void)
{
int i, j;
int a[4][3] = {{74,85,69},{14,25,36},{45,65,96},{58,47,56}};
int b[4][3] = {{45,56,74},{25,14,36},{85,74,96},{25,74,85}};
int c[4][3];
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
c[i][j] = a[i][j] + b[i][j];
}
}
puts("array1 :");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
printf("%3d", a[i][j]);
}
putchar('\n');
}
puts("arrar2 :");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
printf("%3d", b[i][j]);
}
putchar('\n');
}
puts("sum :");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
printf("%4d", c[i][j]);
}
putchar('\n');
}
return 0;
}
标签:25,中求,++,元素,int,74,数组,printf,85
来源: https://www.cnblogs.com/liujiaxin2018/p/14587789.html