题目描述
给出两个 3*3 矩阵 , 让两个矩阵对应位置元素相加。
输入
两个 3*3 矩阵
输出
对应位置相加之后的矩阵
样例输入
0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1
样例输出
1 1 1 1 1 1 1 1 1
代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,x,y,z,e;
int m[3][3],n[3][3],a[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&m[i][j]);
}
}
for(x=0;x<3;x++)
{
for(y=0;y<3;y++)
{
scanf("%d",&n[x][y]);
}
}
for(z=0;z<3;z++)
{
for(e=0;e<3;e++)
{
a[z][e]=m[z][e]+n[z][e];
printf("%d ",a[z][e]);
}
printf("\n");
}
return 0;
}