1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include<iostream>
using namespace std;
#include<stdlib.h>
int main()
{
int r1,r2,r3,r4,r5,r6,r7,r8,r9;
int m1,m2,m3,m4,m5,m6,m7,m8,m9;
cout<<"enter the matrix elements ";
cin>>r1>>r2>>r3>>r4>>r5>>r6>>r7>>r8>>r9;
cout<<"enter the elements of second matrix ";
cin>>m1>>m2>>m3>>m4>>m5>>m6>>m7>>m8>>m9;
system ("cls");
int matrix1[3][3] = {
{r1,r2,r3},
{r4,r5,r6},
{r7,r8,r9}
};
int a,b;
for(b = 0; b < 3; ++b)
{
for(a = 0; a < 3; ++a)
cout << matrix1[b][a];
cout<<endl;
}
cout<<endl;
int matrix2[3][3] = {
{m1,m2,m3},
{m4,m5,m6},
{m7,m8,m9}
};
int c,d;
for(d = 0; d < 3; ++d)
{
for(c = 0; c < 3; ++c)
cout << matrix1[d][c];
cout<<endl;
}
cout<<endl;
int matrix[3][3] = {
{r1+m1,r2+m2,r3+m3},
{r4+m4,r5+m5,r6+m6},
{r7+m7,r8+m8,r9+m9}
};
int x,y;
for(y = 0; y < 3; ++y)
{
for(x = 0; x < 3; ++x)
cout <<matrix[y][x]<<"|";
cout << endl;
}
return 0;
|