#include

#define MAX 50

using namespace std;

int chiedidimensione();

void Caricamento(int matr[MAX][MAX], int r, int c);

void Stampa(int matr[MAX][MAX],int r,int c);

void SommaMatrici(int M1[MAX][MAX], int M2[MAX][MAX], int r, int c);

int main()

{

int r, c, r1, c2;

int mat1[MAX][MAX], mat2[MAX][MAX];

cout;

r=chiedidimensione();

cout

c=chiedidimensione();

Caricamento(mat1, r, c);

cout

r1=chiedidimensione();

cout

c2=chiedidimensione();

Caricamento(mat2, r1, c2);

if((r==r1 )&& (c==c2)) {

SommaMatrici(mat1, mat2, r, c);

}

else {

cout

}

return 0;

}

int chiedidimensione()

{

int d;

do{

cin>>d;

}while(dMAX);

return d;

}

void Caricamento(int matr[MAX][MAX], int r, int c){

cout

for(int x=0; x

for(int y=0; y

cin>>matr[x][y];

}

}

cout

Stampa(matr,r,c);

}

void Stampa(int matr[MAX][MAX],int r,int c){

for(int x=0;x

for(int y=0; y

cout

}cout

}

}

void SommaMatrici(int M1[MAX][MAX], int M2[MAX][MAX], int r, int c){

int M3[MAX][MAX];

for (int i=0; i

for (int j=0; j

M3[j]=M1[j]+M2[j];

} }

cout

Stampa(M3, r, c);

}

Domande e risposte

Hai bisogno di aiuto?
Chiedi alla community