A community for students.
Here's the question you clicked on:
 0 viewing

This Question is Closed

nickymarden
 2 years ago
Best ResponseYou've already chosen the best response.0#include <stdio.h> #include <stdlib.h> void lerMatriz(int *mat, int m, int n) { // incremento do endereco contido na variavel auxiliar int i, j; for (i = 0; i < m; i = i + 1) for (j = 0; j < n; j = j + 1) scanf("%d", &mat[i * n + j]); } void somarMatrizes(int *a, int *b, int *c, int m, int n) { int i, j, k; for (i = 0; i < m; i = i + 1) { k = i * n; for (j = 0; j < n; j = j + 1) c[k + j] = a[k + j] + b[k + j]; } } void escreverMatriz(int *mat, int m, int n) { // base (mat) mais deslocamento (i * m + j) int i, j, k; for (i = 0; i < m; i = i + 1) { k = i * n; for (j = 0; j < n; j = j + 1) printf("%3d", mat[k + j]); printf("\n"); } } int main(void) { int m, n, *m1, *m2, *m3; scanf("%d", &m); scanf("%d", &n); m1 = (int *)malloc(sizeof(int) * m * n); m2 = (int *)malloc(sizeof(int) * m * n); m3 = (int *)malloc(sizeof(int) * m * n); lerMatriz(m1, m, n); escreverMatriz(m1, m, n); lerMatriz(m2, m, n); escreverMatriz(m2, m, n); printf("\n"); somarMatrizes(m1, m2, m3, m, n); escreverMatriz(m3, m, n); system("RETURN"); }

bdean20
 2 years ago
Best ResponseYou've already chosen the best response.1Seems to work just fine for me. I don't know what the system("RETURN") is doing there, though. This is the exact code I was using: http://pastebin.com/FaW39mdS
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.