2 d array leet code questions ADD TWO MATRICES
1. add two matrices
#include<stdio.h>
int main(){
int arr[2][3]={{1,2,3},{4,5,6}};
int brr[2][3]={{10,9,8},{7,6,5}};
int crr[2][3];
for (int i = 0; i < 2; i++)
{
for(int j=0; j<3; j++){
crr[i][j]=arr[i][j]+brr[i][j];
}
}
for (int i = 0; i < 2; i++)
{
for(int j=0; j<3; j++){
printf("%d ",crr[i][j]);
}
printf("\n");
}
return 0;
}

.png)
Comments
Post a Comment