Você está na página 1de 1

#include <stdio.

h>

#define SIZE 3

// Função: Soma de matrizes


// Entradas: Duas matrizes 3x3 (Mat_A, Mat_B)
// Saídas: Uma matriz 3x3 (Mat_Soma) com os valores resultantes da soma das
matrizes Mat_A e Mat_B
// Autor: Lívia Fátima de Souza do Nascimento
// Data: 22/06

void somarMatrizes(int matA[SIZE][SIZE], int matB[SIZE][SIZE], int matSoma[SIZE]


[SIZE]) {
int i, j;

for (i = 0; i < SIZE; i++) {


for (j = 0; j < SIZE; j++) {
matSoma[i][j] = matA[i][j] + matB[i][j];
}
}
}

int main() {
int Mat_A[SIZE][SIZE];
int Mat_B[SIZE][SIZE];
int Mat_Soma[SIZE][SIZE];
int i, j;

printf("Informe os valores da matriz Mat_A:\n");


for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
printf("Mat_A[%d][%d]: ", i, j);
scanf("%d", &Mat_A[i][j]);
}
}

printf("Informe os valores da matriz Mat_B:\n");


for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
printf("Mat_B[%d][%d]: ", i, j);
scanf("%d", &Mat_B[i][j]);
}
}

somarMatrizes(Mat_A, Mat_B, Mat_Soma);

printf("Matriz Mat_Soma:\n");
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
printf("%d ", Mat_Soma[i][j]);
}
printf("\n");
}

return 0;
}

Você também pode gostar