Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

nickymarden

I've already asked in the ComputerScience section but no one answered. Can someone please tell mw what's wrong with this?

  • one year ago
  • one year ago

  • This Question is Closed
  1. nickymarden
    Best Response
    You've already chosen the best response.
    Medals 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"); }

    • one year ago
  2. A.Avinash_Goutham
    Best Response
    You've already chosen the best response.
    Medals 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; // printf("entered loop\n"); for (i = 0; i < m; i ++) { for (j = 0; j < n; j = j + 1) { printf("enter mat[%d][%d]:",i,j); scanf("%d", &mat[i * n + j]); } } // printf("exit loop"); return; } void somarMatrizes(int *a, int *b, int *c, int m, int n) { int i, j, k; for (i = 0; i < m; i++) { 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; printf("enter m:"); scanf("%d", &m); printf("enter n:"); scanf("%d", &n); m1 = (int *)malloc(sizeof(int) * m * n); //printf("malloc\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"); }

    • one year ago
    • Attachments:

See more questions >>>

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.