Created
May 11, 2015 02:02
-
-
Save rogerioagjr/5f651e2c9a7a2c487ebe to your computer and use it in GitHub Desktop.
Chuva
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#define MAXN 110 | |
int n, matrix[MAXN][MAXN]; | |
int main(){ | |
scanf("%d", &n); // leio o valor de n | |
for(int m=1; m<=2; m++) // para cada uma das duas matrizes que vou ler | |
for(int i=1; i<=n; i++) // para uma das linhas da matriz | |
for(int j=1; j<=n; j++){ // para cada elemento da linha da matriz | |
// declaro e leio o valor de num | |
int num; | |
scanf("%d", &num); | |
// e adiciono seu valor ao elemento corespondente em matrix | |
matrix[i][j]+=num; | |
} | |
for(int i=1; i<=n; i++){ // para cada linha da matriz final | |
for(int j=1; j<=n; j++) // para cada elemento da linha | |
printf("%d ", matrix[i][j]); // imprimo o seu valor seguido de espaço em branco | |
printf("\n"); // e imprimo a quebra de linha no final da linha da matriz | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment